Skip to content

Commit

Permalink
support darkmode
Browse files Browse the repository at this point in the history
  • Loading branch information
QuentinGab committed Sep 24, 2024
1 parent 4488b08 commit cc9f12a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 17 deletions.
35 changes: 22 additions & 13 deletions resources/views/components/banner.blade.php
Original file line number Diff line number Diff line change
@@ -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(),
])

<div wire:ignore
{{ $attributes->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,
Expand Down Expand Up @@ -38,7 +46,7 @@
return cookie ? JSON.parse(cookie) : null;
},
getDefaultConsents() {
return @js(CookiesConsent::getDefaultConsents());
return @js($defaults);
},
getConsents() {
const value = this.getValue();
Expand Down Expand Up @@ -99,22 +107,23 @@
},
<!-- prettier-ignore-start -->
callbacks: {
@foreach(CookiesConsent::getDefinition() as $group)
@foreach($cookies as $group)
'{{ $group->key }}': function() {
{!! value($group->onAccepted) !!}
},
@endforeach
},
<!-- prettier-ignore-end -->
}" x-show="show" x-cloak x-on:cookies-consent.window="show = true">
<div class="min-h-0 overflow-auto rounded-md bg-white shadow-md">
<div class="min-h-0 overflow-auto rounded-md bg-white shadow-md dark:bg-zinc-900 dark:text-white">
<div class="p-4">
<h2 class="mb-1 text-lg font-bold">
{{ __('cookies-consent::cookies.title') }}
</h2>
<p class="mb-3 text-sm">
{{ __('cookies-consent::cookies.intro') }} <br>
@if ($policy = config('cookies-consent.policy'))
<p class="mb-3 text-sm dark:text-white/50">
{{ __('cookies-consent::cookies.intro') }}
@if ($policy)
<br>
{!! __('cookies-consent::cookies.link', ['url' => $policy]) !!}
@endif
</p>
Expand All @@ -140,8 +149,8 @@ class="col-span-2 justify-center rounded-md font-semibold" x-on:click="save">
</div>
</div>
<div x-show="expanded" x-collapse x-cloak>
<div class="divide-y border-t text-sm">
@foreach (CookiesConsent::getDefinition() as $group)
<div class="divide-y border-t text-sm dark:divide-white/20 dark:border-white/20">
@foreach ($cookies as $group)
<div class="p-4" x-data="{ expanded: false }">
<div class="mb-0.5 flex items-center text-base">
<p class="grow font-semibold">
Expand All @@ -154,7 +163,7 @@ class="col-span-2 justify-center rounded-md font-semibold" x-on:click="save">
</label>
</div>

<p class="mb-1 text-gray-600">
<p class="mb-1 text-black/50 dark:text-white/50">
{{ $group->description }}
</p>

Expand All @@ -175,14 +184,14 @@ class="col-span-2 justify-center rounded-md font-semibold" x-on:click="save">
<p>{{ $cookie->formattedLifetime() }}</p>
</div>

<p class="text-xs text-gray-500">{{ $cookie->description }}</p>
<p class="text-xs text-black/50 dark:text-white/50">{{ $cookie->description }}</p>
</div>
@endforeach
</div>
</div>
@endforeach
</div>
<div class="border-t p-4">
<div class="border-t p-4 dark:border-white/20">
<x-cookies-consent::button color="black" class="w-full justify-center rounded-md font-semibold"
x-on:click="save">
{{ __('cookies-consent::cookies.save') }}
Expand Down
10 changes: 7 additions & 3 deletions resources/views/components/button.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion resources/views/components/toggle.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)>

0 comments on commit cc9f12a

Please sign in to comment.