Skip to content
Closed
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
23 changes: 0 additions & 23 deletions app/Http/Middleware/HandleAppearance.php

This file was deleted.

4 changes: 1 addition & 3 deletions bootstrap/app.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?php

use App\Http\Middleware\HandleAppearance;
use App\Http\Middleware\HandleInertiaRequests;
use Illuminate\Foundation\Application;
use Illuminate\Foundation\Configuration\Exceptions;
Expand All @@ -14,10 +13,9 @@
health: '/up',
)
->withMiddleware(function (Middleware $middleware) {
$middleware->encryptCookies(except: ['appearance', 'sidebar_state']);
$middleware->encryptCookies(except: ['sidebar_state']);

$middleware->web(append: [
HandleAppearance::class,
HandleInertiaRequests::class,
AddLinkHeadersForPreloadedAssets::class,
]);
Expand Down
4 changes: 2 additions & 2 deletions resources/js/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { resolvePageComponent } from 'laravel-vite-plugin/inertia-helpers';
import type { DefineComponent } from 'vue';
import { createApp, h } from 'vue';
import { ZiggyVue } from 'ziggy-js';
import { initializeTheme } from './composables/useAppearance';
import { useColorMode } from '@vueuse/core';

// Extend ImportMeta interface for Vite...
declare module 'vite/client' {
Expand Down Expand Up @@ -37,4 +37,4 @@ createInertiaApp({
});

// This will set light / dark mode on page load...
initializeTheme();
useColorMode();
10 changes: 5 additions & 5 deletions resources/js/components/AppearanceTabs.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<script setup lang="ts">
import { useAppearance } from '@/composables/useAppearance';
import { useColorMode } from '@vueuse/core'
import { Monitor, Moon, Sun } from 'lucide-vue-next';

const { appearance, updateAppearance } = useAppearance();
const { store } = useColorMode()

const tabs = [
{ value: 'light', Icon: Sun, label: 'Light' },
{ value: 'dark', Icon: Moon, label: 'Dark' },
{ value: 'system', Icon: Monitor, label: 'System' },
{ value: 'auto', Icon: Monitor, label: 'System' },
] as const;
</script>

Expand All @@ -16,10 +16,10 @@ const tabs = [
<button
v-for="{ value, Icon, label } in tabs"
:key="value"
@click="updateAppearance(value)"
@click="store = value"
:class="[
'flex items-center rounded-md px-3.5 py-1.5 transition-colors',
appearance === value
store === value
? 'bg-white shadow-xs dark:bg-neutral-700 dark:text-neutral-100'
: 'text-neutral-500 hover:bg-neutral-200/60 hover:text-black dark:text-neutral-400 dark:hover:bg-neutral-700/60',
]"
Expand Down
92 changes: 0 additions & 92 deletions resources/js/composables/useAppearance.ts

This file was deleted.

17 changes: 1 addition & 16 deletions resources/views/app.blade.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,9 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}" @class(['dark' => ($appearance ?? 'system') == 'dark'])>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

{{-- Inline script to detect system dark mode preference and apply it immediately --}}
<script>
(function() {
const appearance = '{{ $appearance ?? "system" }}';

if (appearance === 'system') {
const prefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches;

if (prefersDark) {
document.documentElement.classList.add('dark');
}
}
})();
</script>

{{-- Inline style to set the HTML background color based on our theme in app.css --}}
<style>
html {
Expand Down