Skip to content

Commit 9063af5

Browse files
committed
feat(UserMenu): add colors
1 parent c893c2d commit 9063af5

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

src/assets/css/main.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@import "tailwindcss";
1+
@import "tailwindcss" theme(static);
22
@import "@nuxt/ui-pro";
33

44
@theme static {

src/components/UserMenu.vue

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ defineProps<{
88
}>()
99
1010
const colorMode = useColorMode()
11+
const appConfig = useAppConfig()
12+
13+
const colors = ['red', 'orange', 'amber', 'yellow', 'lime', 'green', 'emerald', 'teal', 'cyan', 'sky', 'blue', 'indigo', 'violet', 'purple', 'fuchsia', 'pink', 'rose']
14+
const neutrals = ['slate', 'gray', 'zinc', 'neutral', 'stone']
1115
1216
const user = ref({
1317
name: 'Benjamin Canac',
@@ -32,6 +36,50 @@ const items = computed<DropdownMenuItem[][]>(() => ([[{
3236
icon: 'i-lucide-settings',
3337
to: '/settings'
3438
}], [{
39+
label: 'Theme',
40+
icon: 'i-lucide-palette',
41+
children: [{
42+
label: 'Primary',
43+
slot: 'chip',
44+
chip: appConfig.ui.colors.primary,
45+
content: {
46+
align: 'center',
47+
collisionPadding: 16
48+
},
49+
children: colors.map(color => ({
50+
label: color,
51+
chip: color,
52+
slot: 'chip',
53+
checked: appConfig.ui.colors.primary === color,
54+
type: 'checkbox',
55+
onSelect: (e) => {
56+
e.preventDefault()
57+
58+
appConfig.ui.colors.primary = color
59+
}
60+
}))
61+
}, {
62+
label: 'Neutral',
63+
slot: 'chip',
64+
chip: appConfig.ui.colors.neutral === 'neutral' ? 'old-neutral' : appConfig.ui.colors.neutral,
65+
content: {
66+
align: 'end',
67+
collisionPadding: 16
68+
},
69+
children: neutrals.map(color => ({
70+
label: color,
71+
chip: color === 'neutral' ? 'old-neutral' : color,
72+
slot: 'chip',
73+
type: 'checkbox',
74+
checked: appConfig.ui.colors.neutral === color,
75+
onSelect: (e) => {
76+
e.preventDefault()
77+
78+
appConfig.ui.colors.neutral = color
79+
}
80+
}))
81+
}]
82+
}, {
3583
label: 'Appearance',
3684
icon: 'i-lucide-sun-moon',
3785
children: [{
@@ -100,5 +148,15 @@ const items = computed<DropdownMenuItem[][]>(() => ([[{
100148
trailingIcon: 'text-dimmed'
101149
}"
102150
/>
151+
152+
<template #chip-leading="{ item }">
153+
<span
154+
:style="{
155+
'--chip-light': `var(--color-${(item as any).chip}-500)`,
156+
'--chip-dark': `var(--color-${(item as any).chip}-400)`
157+
}"
158+
class="ms-0.5 size-2 rounded-full bg-(--chip-light) dark:bg-(--chip-dark)"
159+
/>
160+
</template>
103161
</UDropdownMenu>
104162
</template>

0 commit comments

Comments
 (0)