generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e38da0
commit 2dd5be8
Showing
8 changed files
with
329 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,123 @@ | ||
<x-filament::dropdown teleport placement="bottom-end" class="fi-dropdown fi-user-menu"> | ||
@php | ||
$locales = $languageSwitch->getLocales(); | ||
@endphp | ||
<x-filament::dropdown | ||
teleport | ||
placement="bottom" | ||
:width="$languageSwitch->isFlagsOnly() ? 'flags-only' : null" | ||
class="fi-dropdown fi-user-menu" | ||
> | ||
<style> | ||
.filament-dropdown-list-item-label { | ||
display: flex; | ||
justify-content: flex-start; | ||
align-items: center; | ||
.flags-only { | ||
max-width: 3rem!important; | ||
} | ||
</style> | ||
|
||
<x-slot name="trigger" class=""> | ||
<div | ||
class="flex items-center justify-center w-9 h-9 font-semibold text-sm text-white rounded-full language-switch-trigger bg-primary-500 dark:text-primary-500 dark:bg-gray-900 ring-1 ring-inset ring-gray-950/10 dark:ring-white/20"> | ||
{{ \Illuminate\Support\Str::of(app()->getLocale())->length() > 2 | ||
? \Illuminate\Support\Str::of(app()->getLocale())->substr(0, 2)->upper() | ||
: \Illuminate\Support\Str::of(app()->getLocale())->upper() }} | ||
@class([ | ||
"flex items-center justify-center text-sm font-semibold w-9 h-9 language-switch-trigger text-primary-500 bg-primary-500/10", | ||
"rounded-full" => $languageSwitch->isCircular(), | ||
"rounded-lg" => !$languageSwitch->isCircular(), | ||
"p-1 ring-2 ring-inset ring-gray-200 hover:ring-gray-300 dark:ring-gray-500 hover:dark:ring-gray-400" => $languageSwitch->isFlagsOnly(), | ||
]) | ||
@if ($languageSwitch->isFlagsOnly()) | ||
x-tooltip="{ | ||
content: @js($languageSwitch->getLabel(app()->getLocale())), | ||
theme: $store.theme, | ||
placement: 'bottom' | ||
}" | ||
@endif | ||
> | ||
@if ($languageSwitch->isFlagsOnly()) | ||
<img | ||
src="{{ $languageSwitch->getFlag(app()->getLocale()) }}" | ||
@class([ | ||
"object-cover object-center max-w-none", | ||
"rounded-full" => $languageSwitch->isCircular(), | ||
"rounded-md" => !$languageSwitch->isCircular() | ||
]) | ||
/> | ||
@else | ||
<span>{{ $languageSwitch->getFlag(app()->getLocale()) }}</span> | ||
@endif | ||
</div> | ||
</x-slot> | ||
<x-filament::dropdown.list class="!border-t-0"> | ||
@foreach (config('filament-language-switch.locales') as $key => $locale) | ||
@if (!app()->isLocale($key)) | ||
<button type="button" class="fi-dropdown-list-item flex w-full items-center gap-2 whitespace-nowrap rounded-md p-2 text-sm transition-colors duration-75 outline-none disabled:pointer-events-none disabled:opacity-70 fi-dropdown-list-item-color-gray hover:bg-gray-950/5 focus:bg-gray-950/5 dark:hover:bg-white/5 dark:focus:bg-white/5" wire:click="changeLocale('{{ $key }}')"> | ||
|
||
@if (config('filament-language-switch.flag')) | ||
<span> | ||
<x-dynamic-component :component="'flag-1x1-' . (!blank($locale['flag_code']) ? $locale['flag_code'] : 'un')" | ||
class="flex-shrink-0 w-5 h-5 group-hover:text-white group-focus:text-white text-primary-500" | ||
style="border-radius: 0.25rem" /> | ||
</span> | ||
<x-filament::dropdown.list | ||
@class([ | ||
"!border-t-0 space-y-1", | ||
]) | ||
> | ||
@foreach ($locales as $locale) | ||
@if (!app()->isLocale($locale)) | ||
<button | ||
type="button" | ||
wire:click="changeLocale('{{ $locale }}')" | ||
@if ($languageSwitch->isFlagsOnly()) | ||
x-tooltip="{ | ||
content: @js($languageSwitch->getLabel($locale)), | ||
theme: $store.theme, | ||
placement: 'right' | ||
}" | ||
@endif | ||
@class([ | ||
"flex items-center justify-center w-full px-2 py-0.5 text-sm transition-colors duration-75 rounded-md outline-none fi-dropdown-list-item whitespace-nowrap disabled:pointer-events-none disabled:opacity-70 fi-dropdown-list-item-color-gray hover:bg-gray-950/5 focus:bg-gray-950/5 dark:hover:bg-white/5 dark:focus:bg-white/5", | ||
]) | ||
> | ||
|
||
@if ($languageSwitch->isFlagsOnly()) | ||
<img | ||
src="{{ $languageSwitch->getFlag($locale) }}" | ||
@class([ | ||
"object-cover object-center max-w-none w-9 h-9 p-1 ring-2 ring-inset ring-gray-200 hover:ring-gray-300 dark:ring-gray-500 hover:dark:ring-gray-400", | ||
"rounded-full" => $languageSwitch->isCircular(), | ||
"rounded-lg" => !$languageSwitch->isCircular() | ||
]) | ||
/> | ||
@else | ||
|
||
<span | ||
class="w-6 h-6 flex items-center justify-center flex-shrink-0 @if (!app()->isLocale($key)) group-hover:bg-white group-hover:text-primary-600 group-hover:border group-hover:border-primary-500/10 group-focus:text-white @endif bg-primary-500/10 text-primary-500 font-semibold rounded-full p-4 text-xs"> | ||
{{ \Illuminate\Support\Str::of($locale['name'])->snake()->upper()->explode('_')->map(function ($string) use ($locale) { | ||
return \Illuminate\Support\Str::of($locale['name'])->wordCount() > 1 ? \Illuminate\Support\Str::substr($string, 0, 1) : \Illuminate\Support\Str::substr($string, 0, 2); | ||
})->take(2)->implode('') }} | ||
@class([ | ||
"flex items-center justify-center flex-shrink-0 w-6 h-6 p-4 text-xs font-semibold group-hover:bg-white group-hover:text-primary-600 group-hover:border group-hover:border-primary-500/10 group-focus:text-white bg-primary-500/10 text-primary-500", | ||
"rounded-full" => $languageSwitch->isCircular(), | ||
"rounded-lg" => !$languageSwitch->isCircular() | ||
]) | ||
> | ||
{{ $languageSwitch->getFlag($locale) }} | ||
</span> | ||
<span class="text-gray-700 hover:bg-transparent dark:text-gray-200"> | ||
{{ $languageSwitch->getLabel($locale) }} | ||
</span> | ||
@endif | ||
<span class="hover:bg-transparent text-gray-700 dark:text-gray-200"> | ||
{{ \Illuminate\Support\Str::of($locale[config('filament-language-switch.native') ? 'native' : 'name'])->headline() }} | ||
</span> | ||
</button> | ||
@endif | ||
@endforeach | ||
|
||
</x-filament::dropdown.list> | ||
<script> | ||
document.addEventListener('DOMContentLoaded', () => { | ||
window.addEventListener('filament-language-changed', () => { | ||
console.log('Language changed'); | ||
location.reload(true); | ||
}); | ||
}) | ||
</script> | ||
</x-filament::dropdown> | ||
{{-- <x-filament::dropdown> | ||
<x-slot name="trigger"> | ||
<x-filament::button> | ||
More actions | ||
</x-filament::button> | ||
</x-slot> | ||
<x-filament::dropdown.list> | ||
<x-filament::dropdown.list.item | ||
wire:click="openViewModal" | ||
:image="$languageSwitch->getFlag(app()->getLocale())" | ||
:tooltip="$languageSwitch->getLabel(app()->getLocale())" | ||
> | ||
{{ $languageSwitch->getLabel(app()->getLocale()) }} | ||
</x-filament::dropdown.list.item> | ||
<x-filament::dropdown.list.item wire:click="openEditModal" icon="heroicon-m-pencil"> | ||
Edit | ||
</x-filament::dropdown.list.item> | ||
<x-filament::dropdown.list.item wire:click="openDeleteModal"> | ||
Delete | ||
</x-filament::dropdown.list.item> | ||
</x-filament::dropdown.list> | ||
</x-filament::dropdown> --}} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.