Skip to content

Commit fa37a62

Browse files
antfubotantfu
andauthored
feat(docs): move color mode toggle to navbar top right (#307)
Co-authored-by: Anthony Fu <github@antfu.me>
1 parent f808561 commit fa37a62

2 files changed

Lines changed: 102 additions & 2 deletions

File tree

docs/app/assets/css/devframe.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
width: 100%;
4747
}
4848

49-
/* Do not render "description" slot */
50-
[data-slot="description"] {
49+
/* Do not render "description" slot in page, as the content are duplicated */
50+
[data-slot="wrapper"] + [data-slot="description"] {
5151
display: none;
5252
}

docs/app/components/AppHeader.vue

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<script setup lang="ts">
2+
// Shadows the comark-docs layer's AppHeader: adds a color mode toggle to the
3+
// persistent top-right nav, next to the version history button.
4+
const { header, footer, assistant } = useAppConfig()
5+
const content = useDocsContent()
6+
// const historyOpen = useVersionHistory()
7+
const assistantOpen = useAssistant()
8+
const navigation = useMainNavigation()
9+
</script>
10+
11+
<template>
12+
<UHeader :to="prefixLink(header?.to || '/', content.base)">
13+
<template #left>
14+
<AppHeaderBrand />
15+
</template>
16+
17+
<AppHeaderCenter class="hidden lg:flex" />
18+
19+
<template #right>
20+
<UContentSearchButton
21+
v-if="header?.search"
22+
:collapsed="false"
23+
:icon="false"
24+
class="text-muted font-normal hidden lg:inline-flex min-w-[150px]"
25+
/>
26+
27+
<UButton
28+
v-if="assistant?.enabled"
29+
label="Ask AI"
30+
color="neutral"
31+
variant="outline"
32+
@click="assistantOpen = true"
33+
/>
34+
35+
<UColorModeButton
36+
color="neutral"
37+
variant="outline"
38+
:ui="{ leadingIcon: 'size-4' }"
39+
class="p-2"
40+
/>
41+
42+
<!-- <UButton
43+
icon="i-lucide-history"
44+
:color="content.mode === 'prod' ? 'neutral' : 'warning'"
45+
:variant="content.mode === 'prod' ? 'outline' : 'subtle'"
46+
aria-label="Version history"
47+
:ui="{ leadingIcon: 'size-4' }"
48+
class="p-2"
49+
@click="historyOpen = !historyOpen"
50+
/> -->
51+
52+
<template v-if="header?.links">
53+
<UButton
54+
v-for="(link, index) of header?.links"
55+
:key="index"
56+
v-bind="{ color: 'neutral', variant: 'ghost', ...link }"
57+
class="hidden lg:inline-flex"
58+
/>
59+
</template>
60+
</template>
61+
62+
<template #toggle="{ open, toggle }">
63+
<IconMenuToggle
64+
:open="open"
65+
@click="toggle"
66+
/>
67+
</template>
68+
69+
<template #body>
70+
<div class="flex flex-col justify-between h-full">
71+
<div class="flex flex-col gap-4">
72+
<UContentSearchButton
73+
v-if="header?.search"
74+
:collapsed="false"
75+
size="xl"
76+
class="w-full font-normal"
77+
:icon="false"
78+
/>
79+
<UNavigationMenu
80+
:items="navigation"
81+
color="neutral"
82+
variant="link"
83+
orientation="vertical"
84+
:ui="{ root: 'pl-0 -ml-2', link: 'py-2 my-2 text-md' }"
85+
/>
86+
</div>
87+
<div class="flex items-center gap-4">
88+
<template v-if="footer?.links">
89+
<UButton
90+
v-for="(link, index) of footer?.links"
91+
:key="index"
92+
v-bind="{ color: 'neutral', variant: 'ghost', size: 'md', ...link }"
93+
class="text-highlighted"
94+
/>
95+
</template>
96+
</div>
97+
</div>
98+
</template>
99+
</UHeader>
100+
</template>

0 commit comments

Comments
 (0)