optimize theme parts

master
A1Gard 2 days ago
parent 5edcdb19a9
commit 89f80a50ce

@ -77,7 +77,7 @@ class makePart extends Command
}
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 . '.json', json_encode($detail,JSON_PRETTY_PRINT));
file_put_contents($folderPath . '/' . ucfirst($part) . '.php', $handler);

@ -6,6 +6,7 @@ use App\Models\Group;
use App\Models\Category;
use App\Models\Area;
use App\Models\Part;
use App\Models\Post;
use App\Models\Menu;
use App\Models\Product;
use App\Models\Rate;
@ -902,6 +903,23 @@ function getProductsQueryBySetting($key, $limit = 10)
}
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

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

@ -5,11 +5,13 @@
</h1>
</div>
<div id="posts-slider-container">
<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="post-slider">
@ -23,5 +25,12 @@
</div>
@endforeach
</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>
</section>

@ -1,10 +1,10 @@
import {tns} from "tiny-slider/src/tiny-slider";
var postsSlider ;
var postsSlider;
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('#posts-slider')?.forEach(function (el) {
if (el.classList.contains('.tns-slider')){
if (el.classList.contains('.tns-slider')) {
console.log('ignore');
return 'ignore';
}
@ -17,20 +17,24 @@ document.addEventListener('DOMContentLoaded', () => {
mouseDrag: true,
autoplayTimeout: 5000,
gutter: 10,
responsive:{
560:{
responsive: {
560: {
items: 2,
edgePadding: 30,
},
768:{
items: 4,
768: {
items: 3,
edgePadding: 40,
},
1000:{
items: 5,
1000: {
items: 4,
edgePadding: 50,
},
1400:{
1400: {
items: 5,
edgePadding: 60,
},
1700: {
items: 6,
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)
{
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_title';
$setting->value = 'Lorem ipsum dolor sit amet';
$setting->type = 'TEXT';
$setting->size = 12;
$setting->title = $part->area_name . ' ' . $part->part .' title';
$setting->key = $part->area_name . '_' . $part->part.'_query';
$setting->value = Group::first()->id.',id,DESC';
$setting->size = 6;
$setting->type = 'POST_QUERY';
$setting->title = $part->area_name . ' ' . $part->part. ' query';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_group';
$setting->value = Group::first()->id;
$setting->key = $part->area_name . '_' . $part->part.'_title';
$setting->value = 'Lorem ipsum dolor sit amet';
$setting->type = 'TEXT';
$setting->size = 6;
$setting->type = 'GROUP';
// $setting->data = json_encode(['xmin' => 2, 'xmax' => 90]);
$setting->title = $part->area_name . ' ' . $part->part. ' group';
$setting->title = $part->area_name . ' ' . $part->part .' title';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_color';

@ -3,6 +3,7 @@
padding: 3rem 0;
background: var(--post-slider-color);
color: var(--xshop-diff);
position: relative;
h1{
font-size: 30px;
@ -31,10 +32,13 @@
background: linear-gradient(-90deg, var(--post-slider-color) 20%, rgba(0,0,0,0) 100%);
}
}
.post-slider{
border-radius: var(--xshop-border-radius);
position: relative;
margin-bottom: 1rem;
img{
width: 100%;
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">
@foreach(\App\Models\Product::where('status',1)->orderByDesc('id')->limit(4)->get() as $product)
<div class="col-lg-3 col-md-6">
<div class="product-item">
@include(\App\Models\Area::where('name','product-grid')->first()->defPart(),compact('product'))
</div>
</div>
@endforeach
</div>
<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']}}">
<h1>
{{getSetting($part->area_name . '_' . $part->part.'_title')}}

Loading…
Cancel
Save