File tree 5 files changed +8
-14
lines changed
5 files changed +8
-14
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,7 @@ public function share(Request $request): array
50
50
...(new Ziggy )->toArray (),
51
51
'location ' => $ request ->url (),
52
52
],
53
+ 'sidebarOpen ' => ! $ request ->hasCookie ('sidebar_state ' ) || $ request ->cookie ('sidebar_state ' ) === 'true ' ,
53
54
];
54
55
}
55
56
}
Original file line number Diff line number Diff line change 14
14
health: '/up ' ,
15
15
)
16
16
->withMiddleware (function (Middleware $ middleware ) {
17
- $ middleware ->encryptCookies (except: ['appearance ' ]);
17
+ $ middleware ->encryptCookies (except: ['appearance ' , ' sidebar_state ' ]);
18
18
19
19
$ middleware ->web (append: [
20
20
HandleAppearance::class,
Original file line number Diff line number Diff line change 1
1
<script setup lang="ts">
2
2
import { SidebarProvider } from ' @/components/ui/sidebar' ;
3
- import { onMounted , ref } from ' vue' ;
3
+ import { usePage } from ' @inertiajs/vue3' ;
4
+ import { SharedData } from ' @/types' ;
4
5
5
6
interface Props {
6
7
variant? : ' header' | ' sidebar' ;
7
8
}
8
9
9
10
defineProps <Props >();
10
11
11
- const isOpen = ref (true );
12
-
13
- onMounted (() => {
14
- isOpen .value = localStorage .getItem (' sidebar' ) !== ' false' ;
15
- });
16
-
17
- const handleSidebarChange = (open : boolean ) => {
18
- isOpen .value = open ;
19
- localStorage .setItem (' sidebar' , String (open ));
20
- };
12
+ const isOpen = usePage <SharedData >().props .sidebarOpen ;
21
13
</script >
22
14
23
15
<template >
24
16
<div v-if =" variant === 'header'" class =" flex min-h-screen w-full flex-col" >
25
17
<slot />
26
18
</div >
27
- <SidebarProvider v-else :default-open =" isOpen" :open = " isOpen " @update:open = " handleSidebarChange " >
19
+ <SidebarProvider v-else :default-open =" isOpen" >
28
20
<slot />
29
21
</SidebarProvider >
30
22
</template >
Original file line number Diff line number Diff line change 1
1
import { createContext } from 'radix-vue' ;
2
2
import type { ComputedRef , Ref } from 'vue' ;
3
3
4
- export const SIDEBAR_COOKIE_NAME = 'sidebar:state ' ;
4
+ export const SIDEBAR_COOKIE_NAME = 'sidebar_state ' ;
5
5
export const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7 ;
6
6
export const SIDEBAR_WIDTH = '16rem' ;
7
7
export const SIDEBAR_WIDTH_MOBILE = '18rem' ;
Original file line number Diff line number Diff line change @@ -23,6 +23,7 @@ export interface SharedData extends PageProps {
23
23
quote : { message : string ; author : string } ;
24
24
auth : Auth ;
25
25
ziggy : Config & { location : string } ;
26
+ sidebarOpen : boolean ;
26
27
}
27
28
28
29
export interface User {
You can’t perform that action at this time.
0 commit comments