optimize theme parts

master
A1Gard 3 days ago
parent 5edcdb19a9
commit 89f80a50ce

@ -77,7 +77,7 @@ class makePart extends Command
} }
DOC; DOC;
file_put_contents($folderPath . '/' . $part . '.blade.php', "<section class='{$part}'></section>"); file_put_contents($folderPath . '/' . $part . '.blade.php', str_replace('THEME_PART_NAME',$part,'<section class="THEME_PART_NAME live-setting" data-live="{{$data->area_name.\'_\'.$data->part}}" ></section>'));
file_put_contents($folderPath . '/' . $part . '.js', ''); file_put_contents($folderPath . '/' . $part . '.js', '');
file_put_contents($folderPath . '/' . $part . '.json', json_encode($detail,JSON_PRETTY_PRINT)); file_put_contents($folderPath . '/' . $part . '.json', json_encode($detail,JSON_PRETTY_PRINT));
file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler); file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler);

@ -6,6 +6,7 @@ use App\Models\Group;
use App\Models\Category; use App\Models\Category;
use App\Models\Area; use App\Models\Area;
use App\Models\Part; use App\Models\Part;
use App\Models\Post;
use App\Models\Menu; use App\Models\Menu;
use App\Models\Product; use App\Models\Product;
use App\Models\Rate; use App\Models\Rate;
@ -902,6 +903,23 @@ function getProductsQueryBySetting($key, $limit = 10)
} }
return $q->orderBy($data[1], $data[2])->limit($limit)->get(); return $q->orderBy($data[1], $data[2])->limit($limit)->get();
} }
/**
* get posts by setting key
* @param $key
* @param integer $limit
* @return \App\Models\Post[]|\Illuminate\Database\Eloquent\Collection|\LaravelIdea\Helper\App\Models\_IH_Post_C
*/
function getPostsQueryBySetting($key, $limit = 10)
{
$data = explode(',', getSetting($key) ?? '1,id,DESC');
if ($data[0] == 0) {
$q = Post::where('status', 1);
}else{
$q = Group::where('id', $data[0])->first()
->posts()->where('status', 1);
}
return $q->orderBy($data[1], $data[2])->limit($limit)->get();
}
/** /**
* get group's posts by setting key * get group's posts by setting key

@ -151,7 +151,7 @@
</span> </span>
<searchable-select <searchable-select
@error($setting->key) :err="true" @enderror @error($setting->key) :err="true" @enderror
:items='@json($groups)' :items='@json($groupz)'
title-field="name" title-field="name"
value-field="id" value-field="id"
xlang="{{config('app.locale')}}" xlang="{{config('app.locale')}}"

@ -5,11 +5,13 @@
</h1> </h1>
</div> </div>
<div id="posts-slider-container"> <div id="posts-slider-container">
<div id="posts-slider"> <div id="posts-slider">
@foreach( getGroupPostsBySetting($data->area_name.'_'.$data->part.'_group',10) as $post )
@foreach( getPostsQueryBySetting($data->area_name.'_'.$data->part.'_query',10) as $post )
<div class="item slider-content"> <div class="item slider-content">
<div class="post-slider"> <div class="post-slider">
@ -23,5 +25,12 @@
</div> </div>
@endforeach @endforeach
</div> </div>
</div>
<div id="pst-nxt" class="sld-btn">
<i class="ri-arrow-right-line"></i>
</div>
<div id="pst-prv" class="sld-btn">
<i class="ri-arrow-left-line"></i>
</div> </div>
</section> </section>

@ -1,10 +1,10 @@
import {tns} from "tiny-slider/src/tiny-slider"; import {tns} from "tiny-slider/src/tiny-slider";
var postsSlider ; var postsSlider;
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('#posts-slider')?.forEach(function (el) { document.querySelectorAll('#posts-slider')?.forEach(function (el) {
if (el.classList.contains('.tns-slider')){ if (el.classList.contains('.tns-slider')) {
console.log('ignore'); console.log('ignore');
return 'ignore'; return 'ignore';
} }
@ -17,20 +17,24 @@ document.addEventListener('DOMContentLoaded', () => {
mouseDrag: true, mouseDrag: true,
autoplayTimeout: 5000, autoplayTimeout: 5000,
gutter: 10, gutter: 10,
responsive:{ responsive: {
560:{ 560: {
items: 2, items: 2,
edgePadding: 30, edgePadding: 30,
}, },
768:{ 768: {
items: 4, items: 3,
edgePadding: 40, edgePadding: 40,
}, },
1000:{ 1000: {
items: 5, items: 4,
edgePadding: 50, edgePadding: 50,
}, },
1400:{ 1400: {
items: 5,
edgePadding: 60,
},
1700: {
items: 6, items: 6,
edgePadding: 60, edgePadding: 60,
}, },
@ -40,4 +44,19 @@ document.addEventListener('DOMContentLoaded', () => {
}); });
}); });
document.querySelector('#pst-nxt')?.addEventListener('click',function () {
if (document.documentElement.getAttribute('dir') === 'rtl'){
postsSlider.goTo('prev');
}else{
postsSlider.goTo('next');
}
});
document.querySelector('#pst-prv')?.addEventListener('click',function () {
if (document.documentElement.getAttribute('dir') !== 'rtl'){
postsSlider.goTo('prev');
}else{
postsSlider.goTo('next');
}
});
}); });

@ -10,27 +10,30 @@ class PostsSlider
{ {
public static function onAdd(Part $part = null) public static function onAdd(Part $part = null)
{ {
$setting = new Setting(); $setting = new Setting();
$setting->section = 'theme'; $setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_title'; $setting->key = $part->area_name . '_' . $part->part.'_query';
$setting->value = 'Lorem ipsum dolor sit amet'; $setting->value = Group::first()->id.',id,DESC';
$setting->type = 'TEXT'; $setting->size = 6;
$setting->size = 12; $setting->type = 'POST_QUERY';
$setting->title = $part->area_name . ' ' . $part->part .' title'; $setting->title = $part->area_name . ' ' . $part->part. ' query';
$setting->save(); $setting->save();
$setting = new Setting(); $setting = new Setting();
$setting->section = 'theme'; $setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_group'; $setting->key = $part->area_name . '_' . $part->part.'_title';
$setting->value = Group::first()->id; $setting->value = 'Lorem ipsum dolor sit amet';
$setting->type = 'TEXT';
$setting->size = 6; $setting->size = 6;
$setting->type = 'GROUP'; $setting->title = $part->area_name . ' ' . $part->part .' title';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
$setting->title = $part->area_name . ' ' . $part->part. ' group';
$setting->save(); $setting->save();
$setting = new Setting(); $setting = new Setting();
$setting->section = 'theme'; $setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_color'; $setting->key = $part->area_name . '_' . $part->part.'_color';

@ -3,6 +3,7 @@
padding: 3rem 0; padding: 3rem 0;
background: var(--post-slider-color); background: var(--post-slider-color);
color: var(--xshop-diff); color: var(--xshop-diff);
position: relative;
h1{ h1{
font-size: 30px; font-size: 30px;
@ -31,10 +32,13 @@
background: linear-gradient(-90deg, var(--post-slider-color) 20%, rgba(0,0,0,0) 100%); background: linear-gradient(-90deg, var(--post-slider-color) 20%, rgba(0,0,0,0) 100%);
} }
} }
.post-slider{ .post-slider{
border-radius: var(--xshop-border-radius); border-radius: var(--xshop-border-radius);
position: relative; position: relative;
margin-bottom: 1rem;
img{ img{
width: 100%; width: 100%;
height: 35vh; height: 35vh;
@ -64,4 +68,48 @@
} }
} }
.tns-nav{
position: absolute;
display: flex !important;
width: 200px;
left: 50%;
height: 50px;
bottom: -2rem;
transform: translateX(-50%);
align-items: center;
justify-content: center;
button{
display: inline-block;
margin: 7px;
width: 10px;
height: 10px;
border-radius: var(--xshop-border-radius);
background: #ffffff;
border: 0;
}
.tns-nav-active{
background: var(--xshop-secondary);
}
}
.sld-btn{
position: absolute;
top: 47%;
cursor: pointer;
z-index: 55;
i{
font-size: 35px;
}
}
#pst-nxt{
right: 45px;
}
#pst-prv{
left: 45px;
}
} }

@ -6,8 +6,10 @@
<div class="row"> <div class="row">
@foreach(\App\Models\Product::where('status',1)->orderByDesc('id')->limit(4)->get() as $product) @foreach(\App\Models\Product::where('status',1)->orderByDesc('id')->limit(4)->get() as $product)
<div class="col-lg-3 col-md-6"> <div class="col-lg-3 col-md-6">
<div class="product-item">
@include(\App\Models\Area::where('name','product-grid')->first()->defPart(),compact('product')) @include(\App\Models\Area::where('name','product-grid')->first()->defPart(),compact('product'))
</div> </div>
</div>
@endforeach @endforeach
</div> </div>
<div class="p-4 text-center mt-2"> <div class="p-4 text-center mt-2">

@ -1,4 +1,4 @@
<section class='ProductsSlider'> <section class='ProductsSlider live-setting' data-live='{{$data->area_name.'_'.$data->part}}' >
<div class="{{gfx()['container']}}"> <div class="{{gfx()['container']}}">
<h1> <h1>
{{getSetting($part->area_name . '_' . $part->part.'_title')}} {{getSetting($part->area_name . '_' . $part->part.'_title')}}

Loading…
Cancel
Save