Skip to content

Dark mode #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/pulse.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion resources/views/components/card-title.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<h2 {{ $attributes->merge(['class' => 'text-base font-bold text-gray-600']) }}>
<h2 {{ $attributes->merge(['class' => 'text-base font-bold text-gray-600 dark:text-gray-300']) }}>
{{ $slot }}
</h2>
2 changes: 1 addition & 1 deletion resources/views/components/card.blade.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div {{ $attributes->merge(['class' => 'flex flex-col p-6 bg-white rounded-lg shadow-sm ring-1 ring-gray-900/5']) }}>
<div {{ $attributes->merge(['class' => 'flex flex-col p-6 bg-white dark:bg-gray-900 rounded-lg shadow-sm ring-1 ring-gray-900/5']) }}>
<div class="flex items-center justify-between">
{{ $title }}
</div>
Expand Down
8 changes: 4 additions & 4 deletions resources/views/components/http-method-badge.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

@php
$colorClasses = match ($method) {
'GET', 'OPTIONS' => 'text-purple-400 bg-purple-50 border-purple-200',
'POST', 'PUT', 'PATCH' => 'text-blue-400 bg-blue-50 border-blue-200',
'DELETE' => 'text-red-400 bg-red-50 border-red-200',
default => 'text-gray-400 bg-gray-50 border-gray-200',
'GET', 'OPTIONS' => 'text-purple-400 dark:text-purple-300 bg-purple-50 dark:bg-purple-900 border-purple-200 dark:border-purple-700',
'POST', 'PUT', 'PATCH' => 'text-blue-400 dark:text-blue-300 bg-blue-50 dark:bg-blue-900 border-blue-200 dark:border-blue-700',
'DELETE' => 'text-red-400 dark:text-red-300 bg-red-50 dark:bg-red-900 border-red-200 dark:border-red-700',
default => 'text-gray-400 dark:text-gray-100 bg-gray-50 dark:bg-gray-700 border-gray-200 dark:border-gray-500',
}
@endphp

Expand Down
10 changes: 5 additions & 5 deletions resources/views/components/placeholder.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<x-pulse::card class="animate-pulse col-span-{{ $cols }}">
<x-pulse::card class="col-span-{{ $cols }}">
<x-slot:title>
<div class="h-[30px] flex items-center w-full">
<div class="rounded bg-gray-50 h-6 w-1/2"></div>
<div class="rounded bg-gray-50 dark:bg-gray-800 h-6 w-1/2 animate-pulse"></div>
</div>
</x-slot:title>
<div class="space-y-4 h-56">
<div class="rounded bg-gray-50 h-12"></div>
<div class="rounded bg-gray-50 h-12"></div>
<div class="rounded bg-gray-50 h-12"></div>
<div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
<div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
<div class="rounded bg-gray-50 dark:bg-gray-800 h-12 animate-pulse"></div>
</div>
</x-pulse::card>
11 changes: 7 additions & 4 deletions resources/views/components/pulse.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
</script>
</head>
<body class="font-sans antialiased">
<div class="bg-gray-50 min-h-screen">
<div class="bg-gray-50 dark:bg-gray-950 min-h-screen">
<header class="px-5">
<div class="{{ $fullWidth ? '' : 'container' }} py-5 mx-auto border-b">
<div class="{{ $fullWidth ? '' : 'container' }} py-5 mx-auto border-b border-gray-200 dark:border-gray-900">
<div class="flex items-center justify-between">
<div class="flex items-center">
<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
Expand All @@ -34,9 +34,12 @@
</linearGradient>
</defs>
</svg>
<span class="ml-2 text-2xl text-gray-700 font-medium"><b class="font-bold">Laravel</b> Pulse</span>
<span class="ml-2 text-2xl text-gray-700 dark:text-gray-300 font-medium"><b class="font-bold">Laravel</b> Pulse</span>
</div>
<div class="flex items-center gap-6">
<livewire:period-selector />
<x-pulse::theme-switcher />
</div>
<livewire:period-selector />
</div>
</div>
</header>
Expand Down
10 changes: 5 additions & 5 deletions resources/views/components/servers-placeholder.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="h-[52px] flex items-center justify-between animate-pulse col-span-{{ $cols }}">
<div class="mt-4 h-8 w-1/12 bg-gray-100 rounded"></div>
<div class="mt-4 h-8 w-3/12 bg-gray-100 rounded"></div>
<div class="mt-4 h-8 w-3/12 bg-gray-100 rounded"></div>
<div class="mt-4 h-8 w-2/12 bg-gray-100 rounded"></div>
<div class="h-[52px] flex items-center justify-between col-span-{{ $cols }}">
<div class="mt-4 h-8 w-1/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
<div class="mt-4 h-8 w-3/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
<div class="mt-4 h-8 w-3/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
<div class="mt-4 h-8 w-2/12 bg-gray-100 dark:bg-gray-900 rounded animate-pulse"></div>
</div>
2 changes: 1 addition & 1 deletion resources/views/components/td.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<td {{ $attributes->merge(['class' => 'first:rounded-l-md last:rounded-r-md bg-gray-50 p-3']) }}>
<td {{ $attributes->merge(['class' => 'first:rounded-l-md last:rounded-r-md bg-gray-50 dark:bg-gray-800 p-3']) }}>
{{ $slot }}
</td>
2 changes: 1 addition & 1 deletion resources/views/components/thead.blade.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<thead class="sticky top-0 p-2 bg-white">
<thead class="sticky top-0 p-2 bg-white dark:bg-gray-900">
{{ $slot }}
</thead>
72 changes: 72 additions & 0 deletions resources/views/components/theme-switcher.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<script>
setDarkClass = () => {
if (localStorage.theme === 'dark' || (!('theme' in localStorage) && window.matchMedia('(prefers-color-scheme: dark)').matches)) {
document.documentElement.classList.add('dark')
} else {
document.documentElement.classList.remove('dark')
}
}

setDarkClass()

window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', setDarkClass)
</script>

<div
class="relative"
x-data="{
menu: false,
theme: localStorage.theme,
darkMode() {
this.theme = 'dark'
localStorage.theme = 'dark'
setDarkClass()
},
lightMode() {
this.theme = 'light'
localStorage.theme = 'light'
setDarkClass()
},
systemMode() {
this.theme = undefined
localStorage.removeItem('theme')
setDarkClass()
},
}"
@click.outside="menu = false"
>
<button
x-cloak
class="block p-1 rounded hover:bg-gray-100 dark:hover:bg-gray-800"
:class="theme ? 'text-gray-700 dark:text-gray-300' : 'text-gray-400 dark:text-gray-600 hover:text-gray-500 focus:text-gray-500 dark:hover:text-gray-500 dark:focus:text-gray-500'"
@click="menu = ! menu"
>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="block dark:hidden w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" />
</svg>
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor" class="hidden dark:block w-5 h-5">
<path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" />
</svg>
</button>

<div x-show="menu" class="absolute origin-top-right right-0 bg-white dark:bg-gray-800 rounded-md ring-1 ring-gray-900/5 shadow-xl flex flex-col" style="display: none;" @click="menu = false">
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700" :class="theme === 'light' ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'" @click="lightMode()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-5 h-5 stroke-current">
<path stroke-linecap="round" stroke-linejoin="round" d="M12 3v2.25m6.364.386l-1.591 1.591M21 12h-2.25m-.386 6.364l-1.591-1.591M12 18.75V21m-4.773-4.227l-1.591 1.591M5.25 12H3m4.227-4.773L5.636 5.636M15.75 12a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0z" />
</svg>
Light
</button>
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700" :class="theme === 'dark' ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'" @click="darkMode()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-5 h-5 stroke-current">
<path stroke-linecap="round" stroke-linejoin="round" d="M21.752 15.002A9.718 9.718 0 0118 15.75c-5.385 0-9.75-4.365-9.75-9.75 0-1.33.266-2.597.748-3.752A9.753 9.753 0 003 11.25C3 16.635 7.365 21 12.75 21a9.753 9.753 0 009.002-5.998z" />
</svg>
Dark
</button>
<button class="flex items-center px-4 py-2 gap-3 hover:bg-gray-100 dark:hover:bg-gray-700" :class="theme === undefined ? 'text-gray-900 dark:text-gray-100' : 'text-gray-500 dark:text-gray-400'" @click="systemMode()">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-5 h-5 stroke-current">
<path stroke-linecap="round" stroke-linejoin="round" d="M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25" />
</svg>
System
</button>
</div>
</div>
28 changes: 13 additions & 15 deletions resources/views/livewire/cache.blade.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<x-pulse::card class="col-span-{{ $cols }}">
<x-slot:title>
<x-pulse::card-title class="flex items-center">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-6 h-6 mr-2 stroke-gray-500">
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" class="w-6 h-6 mr-2 stroke-gray-500 dark:stroke-gray-600">
<path stroke-linecap="round" stroke-linejoin="round" d="M15.59 14.37a6 6 0 01-5.84 7.38v-4.8m5.84-2.58a14.98 14.98 0 006.16-12.12A14.98 14.98 0 009.631 8.41m5.96 5.96a14.926 14.926 0 01-5.841 2.58m-.119-8.54a6 6 0 00-7.381 5.84h4.8m2.581-5.84a14.927 14.927 0 00-2.58 5.84m2.699 2.7c-.103.021-.207.041-.311.06a15.09 15.09 0 01-2.448-2.448 14.9 14.9 0 01.06-.312m-2.24 2.39a4.493 4.493 0 00-1.757 4.306 4.493 4.493 0 004.306-1.758M16.5 9a1.5 1.5 0 11-3 0 1.5 1.5 0 013 0z" />
</svg>
<span>
<span title="Global Time: {{ $allTime }}; Global run at: {{ $allRunAt }}; Monitored Time: {{ $monitoredTime }}; Monitored run at: {{ $monitoredRunAt }};">Cache</span>
<small class="ml-2 text-gray-400 text-xs font-medium">past {{ $this->periodForHumans() }}</small>
<small class="ml-2 text-gray-400 dark:text-gray-600 text-xs font-medium">past {{ $this->periodForHumans() }}</small>
</span>
</x-pulse::card-title>
</x-slot:title>
Expand All @@ -27,38 +27,36 @@
<div :class="[loadingNewDataset ? 'opacity-25 animate-pulse' : '', 'space-y-6']">
<div class="grid grid-cols-3 text-center">
<div>
<span class="text-xl uppercase font-bold text-gray-700 tabular-nums">
<span class="text-xl uppercase font-bold text-gray-700 dark:text-gray-300 tabular-nums">
{{ number_format($allCacheInteractions->hits) }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
<span class="text-xs uppercase font-bold text-gray-500 dark:text-gray-400">
Hits
</span>
</div>
<div>
<span class="text-xl uppercase font-bold text-gray-700 tabular-nums">
<span class="text-xl uppercase font-bold text-gray-700 dark:text-gray-300 tabular-nums">
{{ number_format($allCacheInteractions->count - $allCacheInteractions->hits) }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
<span class="text-xs uppercase font-bold text-gray-500 dark:text-gray-400">
Misses
</span>
</div>
<div>
<span class="text-xl uppercase font-bold text-gray-700 tabular-nums">
<span class="text-xl uppercase font-bold text-gray-700 dark:text-gray-300 tabular-nums">
{{ $allCacheInteractions->count > 0 ? round(($allCacheInteractions->hits / $allCacheInteractions->count) * 100, 2).'%' : '-' }}
</span>
<span class="text-xs uppercase font-bold text-gray-500">
<span class="text-xs uppercase font-bold text-gray-500 dark:text-gray-400">
Hit Rate
</span>
</div>
</div>
@if ($monitoredCacheInteractions->isEmpty())
<div class="flex flex-col items-center justify-center p-4 py-6">
<div class="bg-gray-50 rounded-full text-xs leading-none px-2 py-1 text-gray-500">
<div class="bg-gray-50 dark:bg-gray-800 rounded-full text-xs leading-none px-2 py-1 text-gray-500 dark:text-gray-400">
No keys configured to monitor
</div>
</div>

<div class="flex h-32 items-center text-center text-"></div>
@else
<x-pulse::table>
<x-pulse::thead>
Expand All @@ -73,17 +71,17 @@
@foreach ($monitoredCacheInteractions as $interaction)
<tr wire:key="{{ $interaction->key }}">
<x-pulse::td>
<code class="block text-xs text-gray-900">
<code class="block text-xs text-gray-900 dark:text-gray-100">
{{ $interaction->key }}
</code>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm tabular-nums">
<x-pulse::td class="text-right text-gray-700 dark:text-gray-300 text-sm tabular-nums">
<strong>{{ number_format($interaction->hits) }}</strong>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm whitespace-nowrap tabular-nums">
<x-pulse::td class="text-right text-gray-700 dark:text-gray-300 text-sm whitespace-nowrap tabular-nums">
<strong>{{ number_format($interaction->count - $interaction->hits) }}</strong>
</x-pulse::td>
<x-pulse::td class="text-right text-gray-700 text-sm whitespace-nowrap tabular-nums">
<x-pulse::td class="text-right text-gray-700 dark:text-gray-300 text-sm whitespace-nowrap tabular-nums">
<strong>{{ $interaction->count > 0 ? round(($interaction->hits / $interaction->count) * 100, 2).'%' : '-' }}</strong>
</x-pulse::td>
</tr>
Expand Down
Loading