1
1
<template >
2
- <div :class =" tw`min-h-full`" >
2
+ <transition
3
+ :enter-active-class =" tw`duration-150 ease-out`"
4
+ :enter-from-class =" tw`opacity-0`"
5
+ :enter-to-class =" tw`opacity-100`"
6
+ :leave-active-class =" tw`duration-150 ease-in`"
7
+ :leave-from-class =" tw`opacity-100`"
8
+ :leave-to-class =" tw`opacity-0`"
9
+ >
10
+ <div
11
+ v-if =" menuIsOpen"
12
+ @click =" toggleMenu"
13
+ :class =" tw`fixed inset-0 z-20 bg-black bg-opacity-50 lg:hidden`"
14
+ aria-hidden =" true"
15
+ ></div >
16
+ </transition >
17
+
18
+ <button
19
+ @click =" toggleMenu"
20
+ :class ="
21
+ tw`flex lg:hidden w-full items-center space-x-2 cursor-pointer select-none text(gray-500 dark:gray-300 hover:dark:white hover:green-700) p-4 rounded bg-gray-100 dark:bg-gray-700 hover:(bg(green-100 dark:gray-600 opacity-50 dark:opacity-50))`
22
+ "
23
+ >
24
+ <svg
25
+ :class =" tw`w-5`"
26
+ xmlns =" http://www.w3.org/2000/svg"
27
+ fill =" none"
28
+ viewBox =" 0 0 24 24"
29
+ stroke =" currentColor"
30
+ >
31
+ <path
32
+ stroke-linecap =" round"
33
+ stroke-linejoin =" round"
34
+ stroke-width =" 2"
35
+ d =" M4 6h16M4 12h16M4 18h16"
36
+ />
37
+ </svg >
38
+ <div >{{ currentRoute.meta.title }}</div >
39
+ </button >
40
+
41
+ <SidebarWrapper :menuIsOpen =" menuIsOpen" >
3
42
<ul :class =" tw`sticky top-10`" >
4
43
<li :class =" classes.heading" >Getting Started</li >
5
- <SidebarLink to =" /docs/install" >Installation</SidebarLink >
6
- <SidebarLink to =" /docs/theming" >Theming</SidebarLink >
7
- <SidebarLink to =" /docs/guides" >Guides</SidebarLink >
44
+ <SidebarLink @click =" toggleMenu" to =" /docs/install" >
45
+ Installation
46
+ </SidebarLink >
47
+ <SidebarLink @click =" toggleMenu" to =" /docs/theming" >Theming</SidebarLink >
48
+ <SidebarLink @click =" toggleMenu" to =" /docs/guides" >Guides</SidebarLink >
8
49
<li :class =" classes.heading" >
9
50
<div :class =" tw`mt-8`" >Components</div >
10
51
</li >
11
- <SidebarLink to =" /docs/anchor" >Anchor Link</SidebarLink >
12
- <SidebarLink to =" /docs/button" >Button</SidebarLink >
13
- <SidebarLink to =" /docs/dropdown" >Dropdown</SidebarLink >
14
- <SidebarLink to =" /docs/prose" >Prose</SidebarLink >
15
- <SidebarLink to =" /docs/table" >Table</SidebarLink >
52
+ <SidebarLink @click =" toggleMenu" to =" /docs/anchor" >
53
+ Anchor Link
54
+ </SidebarLink >
55
+ <SidebarLink @click =" toggleMenu" to =" /docs/button" >Button</SidebarLink >
56
+ <SidebarLink @click =" toggleMenu" to =" /docs/dropdown" >
57
+ Dropdown
58
+ </SidebarLink >
59
+ <SidebarLink @click =" toggleMenu" to =" /docs/prose" >Prose</SidebarLink >
60
+ <SidebarLink @click =" toggleMenu" to =" /docs/table" >Table</SidebarLink >
16
61
</ul >
17
- </div >
62
+ </SidebarWrapper >
18
63
</template >
19
64
20
65
<script lang="ts">
21
- import { computed , defineComponent } from " vue" ;
66
+ import { computed , defineComponent , ref , watch } from " vue" ;
22
67
import { tw } from " twind" ;
68
+ import router from " @/router/index.ts" ;
69
+ import SidebarWrapper from " @/views/components/SidebarWrapper.vue" ;
23
70
import SidebarLink from " @/views/components/SidebarLink.vue" ;
24
71
25
72
export default defineComponent ({
26
73
components: {
27
74
SidebarLink ,
75
+ SidebarWrapper ,
28
76
},
29
77
setup() {
78
+ const { currentRoute } = router ;
79
+ const menuIsOpen = ref (false );
30
80
const classes = computed (() => {
31
81
return {
32
82
heading: tw ` uppercase text-sm font-bold tracking-widest mb-3 ` ,
33
83
};
34
84
});
35
- return { tw , classes };
85
+
86
+ const toggleMenu = (): void => {
87
+ menuIsOpen .value = ! menuIsOpen .value ;
88
+ };
89
+
90
+ watch (menuIsOpen , (menuIsOpen ) => {
91
+ menuIsOpen
92
+ ? document .body .classList .add (tw ` overflow-hidden ` )
93
+ : document .body .classList .remove (tw ` overflow-hidden ` );
94
+ });
95
+
96
+ return { tw , currentRoute , classes , menuIsOpen , toggleMenu };
36
97
},
37
98
});
38
99
</script >
0 commit comments