Skip to content

Commit

Permalink
Merge pull request #40 from alibaghernia/#39-set-color-for-cateories
Browse files Browse the repository at this point in the history
#39 set color for cateories
  • Loading branch information
alibaghernia authored May 9, 2024
2 parents 4eeb75f + 2b08d0a commit ba3c1de
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/Filament/CafeRestaurant/Resources/CategoryResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ public static function form(Form $form): Form
->label('مخفی کردن')
->helperText('با فعال کردن این گزینه این دسته بندی و آیتم های درونش در منو نمایش داده نخواهد شد.'),

Forms\Components\ColorPicker::make('bg_color')
->label('رنگ پس زمینه')
->helperText('درصورتی که عکسی برای دسته بندی نگذاشته باشید با این رنگ پس زمینه نمایش داده خواهد شد.')
->rgb(),

]);
}
Expand Down
5 changes: 5 additions & 0 deletions app/Helpers/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,8 @@ function domain_route($name, $parameters = [], $absolute = false,): string
}
return route('business-domain.' . $name, $parameters, $absolute);
}

function is_main_domain(): bool
{
return request()->host() === config('app.domains.main');
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->string('bg_color')
->nullable();
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('categories', function (Blueprint $table) {
$table->dropColumn('bg_color');
});
}
};
20 changes: 15 additions & 5 deletions resources/views/main_domain/business/menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,27 +92,37 @@ class="swiper-slide !flex !flex-row !flex-nowrap !items-center
<div
{{-- todo --}}
{{-- class="relative block overflow-hidden cursor-pointer transition-all duration-[.2s] w-[6.7rem] h-[3.7rem] rounded-[1rem]"--}}
class="ci-category relative block overflow-hidden cursor-pointer transition-all duration-[.2s] rounded-[1.625rem] w-[8.7rem] h-[8.7rem] "
class="ci-category relative block overflow-hidden
cursor-pointer transition-all duration-[.2s]
rounded-[1.625rem] w-[8.7rem] h-[8.7rem] "
onclick="scrollIntoCategory({{$category->id}})"
>
@if($category->background_path)
{{-- @dd($category->background_path)--}}
<img
alt="{{$category->name}}" loading="lazy"
decoding="async"
data-nimg="fill" class="z-0 object-cover"
data-nimg="fill"
class="z-0 object-cover"
sizes="100vw"
src="/storage/{{$category->background_path}}"
style="position: absolute; height: 100%; width: 100%; inset: 0px; color: transparent;"
onerror="this.remove()"
>

@elseif($category->bg_color)
@if(!is_main_domain())
<div
class="absolute h-full text-transparent w-full inset-0"
style="background-color: {{$category->bg_color}};"
>
</div>
@endif
@endif
<span
@class([
'absolute inset-0 z-0',
'bg-black/[.4]' => $category->background_path,
'bg-black/[.7]' => !$category->background_path
'bg-black/[.4]' => (!is_main_domain() && ($category->background_path || $category->bg_color)) || $category->background_path,
'bg-black/[.7]' => (is_main_domain() && !$category->background_path) || (!$category->bg_color),
])
></span>
<div
Expand Down

0 comments on commit ba3c1de

Please sign in to comment.