diff --git a/app/Http/Middleware/HandleInertiaRequests.php b/app/Http/Middleware/HandleInertiaRequests.php index 204e9280..daa8675b 100644 --- a/app/Http/Middleware/HandleInertiaRequests.php +++ b/app/Http/Middleware/HandleInertiaRequests.php @@ -50,6 +50,7 @@ public function share(Request $request): array ...(new Ziggy)->toArray(), 'location' => $request->url(), ], + 'sidebarOpen' => $request->cookie('sidebar_state') === 'true', ]; } } diff --git a/bootstrap/app.php b/bootstrap/app.php index 18d301a4..134581ab 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -14,7 +14,7 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - $middleware->encryptCookies(except: ['appearance']); + $middleware->encryptCookies(except: ['appearance', 'sidebar_state']); $middleware->web(append: [ HandleAppearance::class, diff --git a/resources/js/components/AppShell.vue b/resources/js/components/AppShell.vue index 5c532032..2022061d 100644 --- a/resources/js/components/AppShell.vue +++ b/resources/js/components/AppShell.vue @@ -1,6 +1,7 @@ diff --git a/resources/js/components/ui/sidebar/utils.ts b/resources/js/components/ui/sidebar/utils.ts index c19d1214..5b2e8f9a 100644 --- a/resources/js/components/ui/sidebar/utils.ts +++ b/resources/js/components/ui/sidebar/utils.ts @@ -1,7 +1,7 @@ import { createContext } from 'radix-vue'; import type { ComputedRef, Ref } from 'vue'; -export const SIDEBAR_COOKIE_NAME = 'sidebar:state'; +export const SIDEBAR_COOKIE_NAME = 'sidebar_state'; export const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7; export const SIDEBAR_WIDTH = '16rem'; export const SIDEBAR_WIDTH_MOBILE = '18rem'; diff --git a/resources/js/types/index.d.ts b/resources/js/types/index.d.ts index 853da1d9..8a53a5a4 100644 --- a/resources/js/types/index.d.ts +++ b/resources/js/types/index.d.ts @@ -23,6 +23,7 @@ export interface SharedData extends PageProps { quote: { message: string; author: string }; auth: Auth; ziggy: Config & { location: string }; + sidebarOpen: boolean; } export interface User {