From cc9f12a1545e58e494afcc7c2e17311ce40d9110 Mon Sep 17 00:00:00 2001 From: Quentin Gabriele Date: Tue, 24 Sep 2024 15:34:44 +0200 Subject: [PATCH] support darkmode --- resources/views/components/banner.blade.php | 35 +++++++++++++-------- resources/views/components/button.blade.php | 10 ++++-- resources/views/components/toggle.blade.php | 2 +- 3 files changed, 30 insertions(+), 17 deletions(-) diff --git a/resources/views/components/banner.blade.php b/resources/views/components/banner.blade.php index e78e026..2cf8864 100644 --- a/resources/views/components/banner.blade.php +++ b/resources/views/components/banner.blade.php @@ -1,10 +1,18 @@ @use(\Elegantly\CookiesConsent\Facades\CookiesConsent) +@props([ + 'policy' => config('cookies-consent.policy'), + 'name' => CookiesConsent::getCookieName(), + 'lifetime' => config('cookies-consent.cookie.lifetime') / (24 * 60), + 'defaults' => CookiesConsent::getDefaultConsents(), + 'cookies' => CookiesConsent::getDefinition(), +]) +
class(['fixed bottom-0 right-0 z-50 flex max-h-screen w-full max-w-full flex-col p-4 md:w-96']) }} x-data="{ - cookieName: @js(CookiesConsent::getCookieName()), - lifetime: @js(config('cookies-consent.cookie.lifetime') / (24 * 60)), + cookieName: @js($name), + lifetime: @js($lifetime), consents: null, expanded: false, show: false, @@ -38,7 +46,7 @@ return cookie ? JSON.parse(cookie) : null; }, getDefaultConsents() { - return @js(CookiesConsent::getDefaultConsents()); + return @js($defaults); }, getConsents() { const value = this.getValue(); @@ -99,7 +107,7 @@ }, callbacks: { - @foreach(CookiesConsent::getDefinition() as $group) + @foreach($cookies as $group) '{{ $group->key }}': function() { {!! value($group->onAccepted) !!} }, @@ -107,14 +115,15 @@ }, }" x-show="show" x-cloak x-on:cookies-consent.window="show = true"> -
+

{{ __('cookies-consent::cookies.title') }}

-

- {{ __('cookies-consent::cookies.intro') }}
- @if ($policy = config('cookies-consent.policy')) +

+ {{ __('cookies-consent::cookies.intro') }} + @if ($policy) +
{!! __('cookies-consent::cookies.link', ['url' => $policy]) !!} @endif

@@ -140,8 +149,8 @@ class="col-span-2 justify-center rounded-md font-semibold" x-on:click="save">
-
- @foreach (CookiesConsent::getDefinition() as $group) +
+ @foreach ($cookies as $group)

@@ -154,7 +163,7 @@ class="col-span-2 justify-center rounded-md font-semibold" x-on:click="save">

-

+

{{ $group->description }}

@@ -175,14 +184,14 @@ class="col-span-2 justify-center rounded-md font-semibold" x-on:click="save">

{{ $cookie->formattedLifetime() }}

-

{{ $cookie->description }}

+

{{ $cookie->description }}

@endforeach
@endforeach
-
+
{{ __('cookies-consent::cookies.save') }} diff --git a/resources/views/components/button.blade.php b/resources/views/components/button.blade.php index 2517a46..20ea14a 100644 --- a/resources/views/components/button.blade.php +++ b/resources/views/components/button.blade.php @@ -6,9 +6,13 @@ ]) <{!! $tag !!} {!! $attributes->class([ - 'bg-white ring-1 ring-inset ring-black/10 text-black hover:text-black hover:bg-white/95 outline-white' => - $color === 'white', - 'bg-black text-white hover:text-white hover:bg-black outline-black ring-black/20' => $color === 'black', + match ($color) { + 'white' + => 'dark:bg-zinc-800 dark:text-white dark:hover:bg-zinc-700 dark:hover:text-white bg-white ring-1 ring-inset ring-black/10 text-black hover:text-black hover:bg-white/95 outline-white', + 'black' + => 'dark:bg-white dark:text-black dark:hover:bg-white dark:hover:text-black bg-black text-white hover:text-white hover:bg-black outline-black ring-black/20', + default => '', + }, 'text-sm', 'px-3 py-2', 'shrink-0 cursor-pointer relative inline-flex items-center', diff --git a/resources/views/components/toggle.blade.php b/resources/views/components/toggle.blade.php index 33e0066..9243586 100644 --- a/resources/views/components/toggle.blade.php +++ b/resources/views/components/toggle.blade.php @@ -26,6 +26,6 @@ 'checked:after:duration-300 checked:after:translate-x-4', 'disabled:after:bg-opacity-75 disabled:cursor-not-allowed', 'disabled:checked:before:bg-opacity-40', - 'before:checked:bg-emerald-500 dark:before:checked:bg-emerald-500', + 'before:checked:bg-emerald-500 dark:before:checked:bg-emerald-700', ]) !!} type="checkbox" @disabled($disabled) @checked($checked) @required($required)>