Skip to content

Commit

Permalink
use the class inside view itself
Browse files Browse the repository at this point in the history
  • Loading branch information
bezhanSalleh committed Nov 19, 2023
1 parent 7ab3c6e commit 51dd84f
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 25 deletions.
34 changes: 18 additions & 16 deletions resources/views/language-switch.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@php
$languageSwitch = \BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch::make();
$locales = $languageSwitch->getLocales();
$isCircular = $languageSwitch->isCircular();
$isFlagsOnly = $languageSwitch->isFlagsOnly();
Expand All @@ -11,20 +12,21 @@
default => 'bottom-end',
};
@endphp

@if ($isDisplayOn)
<div @class([
'fls-display-on fixed w-full flex p-4 z-50',
'top-0' => str_contains($alignment, 'top'),
'bottom-0' => str_contains($alignment, 'bottom'),
'justify-start' => str_contains($alignment, 'left'),
'justify-end' => str_contains($alignment, 'right'),
'justify-center' => str_contains($alignment, 'center'),
])>
<div class="rounded-lg bg-gray-50 dark:bg-gray-950">
@include('filament-language-switch::switch')
<div>
@if ($isDisplayOn)
<div @class([
'fls-display-on fixed w-full flex p-4 z-50',
'top-0' => str_contains($alignment, 'top'),
'bottom-0' => str_contains($alignment, 'bottom'),
'justify-start' => str_contains($alignment, 'left'),
'justify-end' => str_contains($alignment, 'right'),
'justify-center' => str_contains($alignment, 'center'),
])>
<div class="rounded-lg bg-gray-50 dark:bg-gray-950">
@include('filament-language-switch::switch')
</div>
</div>
</div>
@else
@include('filament-language-switch::switch')
@endif
@else
@include('filament-language-switch::switch')
@endif
</div>
4 changes: 1 addition & 3 deletions resources/views/switch.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ class="fi-dropdown fi-user-menu"
x-tooltip="{
content: @js($languageSwitch->getLabel(app()->getLocale())),
theme: $store.theme,
arrowless: true,
placement: 'right'
placement: 'bottom'
}"
@endif
>
Expand All @@ -43,7 +42,6 @@ class="fi-dropdown fi-user-menu"
x-tooltip="{
content: @js($languageSwitch->getLabel($locale)),
theme: $store.theme,
arrowless: true,
placement: 'right'
}"
@endif
Expand Down
5 changes: 1 addition & 4 deletions src/Http/Livewire/FilamentLanguageSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace BezhanSalleh\FilamentLanguageSwitch\Http\Livewire;

use BezhanSalleh\FilamentLanguageSwitch\LanguageSwitch;
use Illuminate\Contracts\View\View;
use Livewire\Component;

Expand All @@ -22,8 +21,6 @@ public function changeLocale($locale)

public function render(): View
{
return view('filament-language-switch::language-switch', [
'languageSwitch' => LanguageSwitch::make(),
]);
return view('filament-language-switch::language-switch');
}
}
9 changes: 7 additions & 2 deletions src/LanguageSwitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ public static function boot(): void

FilamentView::registerRenderHook(
name: $static->getRenderHook(),
hook: fn (): string => Blade::render('@livewire(\'filament-language-switch\')')
hook: fn (): string => Blade::render('<livewire:filament-language-switch key=\'fls-panels\' />')
);

if ($static->isDisplayOn()) {
FilamentView::registerRenderHook(
name: 'panels::body.end',
hook: fn (): string => Blade::render('@livewire(\'filament-language-switch\')')
hook: fn (): string => Blade::render('@livewire(\'filament-language-switch\', key(\'fls-outside-panels\'))')
);
}
}
Expand Down Expand Up @@ -222,4 +222,9 @@ public function getLabel(string $locale): string
{
return $this->labels[$locale] ?? locale_get_display_name($locale, $this->getDisplayLocale());
}

public function generateId(): string
{
return str()->random(8);
}
}

0 comments on commit 51dd84f

Please sign in to comment.