added Main categories icon theme part

optimize other parts
master
A1Gard 1 month ago
parent 43f8e35d3c
commit fbd2c43f0b

@ -1437,7 +1437,7 @@ function cacheNumber()
* @param $asc
* @return Category[]|\LaravelIdea\Helper\App\Models\_IH_Category_C
*/
function getMainCategory($limit=4,$orderBy = 'id', $asc = 'ASC')
function getMainCategory($limit=4,$orderBy = 'sort', $asc = 'ASC')
{
return \App\Models\Category::whereNull('parent_id')->limit($limit)->orderBy($orderBy,$asc)->get();
}

@ -0,0 +1,26 @@
<section class='MainCategoriesIcon'>
<div class="{{gfx()['container']}}">
<h1 class="text-center">
{{getSetting($part->area_name . '_' . $part->part.'_title')}}
</h1>
<div class="cat-icon-box">
<div class="row">
@foreach(getMainCategory(getSetting($part->area_name . '_' . $part->part.'_limit')) as $category)
<div class="col-md">
<div class=" l-box">
<a class="main-category" href="{{$category->webUrl()}}">
<img src="{{$category->svgUrl()}}" alt="{{$category->name}}"
title="{{$category->name}}">
</a>
</div>
<a class="main-category" href="{{$category->webUrl()}}">
<h4>
{{$category->name}}
</h4>
</a>
</div>
@endforeach
</div>
</div>
</div>
</section>

@ -0,0 +1,10 @@
{
"name": "MainCategoriesIcon",
"version": "1.0",
"author": "xStack",
"email": "xshop@xstack.ir",
"license": "GPL-3.0-or-later",
"url": "https:\/\/xstack.ir",
"author_url": "https:\/\/4xmen.ir",
"packages": []
}

@ -0,0 +1,75 @@
<?php
namespace Resources\Views\Segments;
use App\Models\Part;
use App\Models\Setting;
class MainCategoriesIcon
{
public static function onAdd(Part $part = null)
{
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_bg';
$setting->value = '#ffffff';
$setting->type = 'COLOR';
$setting->data = json_encode(['name' => 'cat-icon-bg']);
$setting->size = 4;
$setting->title = $part->area_name . ' ' . $part->part .' background color';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_box';
$setting->value = gfx()['primary'];
$setting->type = 'COLOR';
$setting->data = json_encode(['name' => 'cat-icon-box']);
$setting->size = 4;
$setting->title = $part->area_name . ' ' . $part->part .' box color';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_text';
$setting->value = '#ffffff';
$setting->type = 'COLOR';
$setting->data = json_encode(['name' => 'cat-icon-text']);
$setting->size =4;
$setting->title = $part->area_name . ' ' . $part->part .' text color';
$setting->save();
$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 = 6;
$setting->title = $part->area_name . ' ' . $part->part .' titles';
$setting->save();
$setting = new Setting();
$setting->section = 'theme';
$setting->key = $part->area_name . '_' . $part->part.'_limit';
$setting->value = '4';
$setting->size = 6;
$setting->type = 'NUMBER';
$setting->data = json_encode(['xmin' => 4, 'xmax' => 12]);
$setting->title = $part->area_name . ' ' . $part->part. ' limit';
$setting->save();
}
public static function onRemove(Part $part = null)
{
Setting::where('key',$part->area_name . '_' . $part->part.'_title')->first()?->delete();
Setting::where('key',$part->area_name . '_' . $part->part.'_limit')->first()?->delete();
Setting::where('key',$part->area_name . '_' . $part->part.'_bg')->first()?->delete();
Setting::where('key',$part->area_name . '_' . $part->part.'_box')->first()?->delete();
Setting::where('key',$part->area_name . '_' . $part->part.'_text')->first()?->delete();
}
public static function onMount(Part $part = null)
{
return $part;
}
}

@ -0,0 +1,51 @@
.MainCategoriesIcon {
// scss
padding: 4rem;
background: var(--cat-icon-bg);
position: relative;
overflow: hidden;
h1 {
position: absolute;
left: 2rem;
top: 1rem;
transform: rotateZ(-90deg);
white-space: nowrap;
font-size: 22px;
text-align: center;
width: 0;
}
.cat-icon-box {
background: var(--cat-icon-box);
padding: 1rem;
border-radius: var(--xshop-border-radius);
.row {
margin: 1rem;
}
.l-box {
border-radius: var(--xshop-border-radius);
margin: 1rem;
background: var(--cat-icon-bg);
text-align: center;
img {
max-width: 70%;
margin: 1rem 0;
}
}
}
h4 {
padding: 1rem 0 0 0;
font-size: 20px;
font-weight: 300;
color: var(--cat-icon-text) !important;
text-align: center;
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 64 KiB

@ -4,7 +4,7 @@
{{getSetting($data->area_name.'_'.$data->part.'_title')}}
</h1>
<div id="main-cats">
@foreach(\App\Models\Category::whereNull('parent_id')->limit(10)->get() as $category)
@foreach(getMainCategory(10) as $category)
<div class="item slider-content">
<a class="main-category" href="{{$category->webUrl()}}">
<img src="{{$category->imgUrl()}}" alt="{{$category->name}}" title="{{$category->name}}" >

@ -9,7 +9,7 @@
</div>
<div id="samira-slider">
@foreach(getCategoryProductBySetting($part->area_name . '_' . $part->part.'_category') as $product)
@foreach(getCategoryProductBySetting($part->area_name . '_' . $part->part.'_category',getSetting($part->area_name . '_' . $part->part.'_limit')) as $product)
<div class="item slider-content">
<div class="row">

@ -2,6 +2,7 @@ import {tns} from "tiny-slider/src/tiny-slider";
var samSlider ;
document.addEventListener('DOMContentLoaded', () => {
document.querySelectorAll('#samira-slider')?.forEach(function (el) {
if (el.classList.contains('.tns-slider')){

Loading…
Cancel
Save