Skip to content

Commit

Permalink
feat: color mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kunish committed Mar 24, 2024
1 parent cd9973b commit eecad9e
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 31 deletions.
66 changes: 44 additions & 22 deletions components/TheHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -90,35 +90,57 @@ const dropdownItems = [
}
]
]
const colorMode = useColorMode()
const isDark = computed({
get() {
return colorMode.value === 'dark'
},
set() {
colorMode.preference = colorMode.value === 'dark' ? 'light' : 'dark'
}
})
</script>

<template>
<header class="flex items-center justify-between py-4">
<TextLogo />

<ClientOnly>
<UDropdown
:items="dropdownItems"
:ui="{ item: { disabled: 'cursor-text select-text' } }"
:popper="{ placement: 'bottom-start' }"
>
<UAvatar size="md" :src="state.avatar" :alt="state.name" />

<template #account>
<span class="truncate font-medium text-gray-900 dark:text-white">
{{ user?.username }}
</span>
</template>

<template #item="{ item }">
<span class="truncate">{{ item.label }}</span>

<UIcon
:name="item.icon"
class="ms-auto h-4 w-4 flex-shrink-0 text-gray-400 dark:text-gray-500"
/>
</template>
</UDropdown>
<div class="flex items-center gap-4">
<UButton
:icon="
isDark ? 'i-heroicons-moon-20-solid' : 'i-heroicons-sun-20-solid'
"
color="gray"
variant="ghost"
aria-label="Theme"
@click="isDark = !isDark"
/>

<UDropdown
:items="dropdownItems"
:ui="{ item: { disabled: 'cursor-text select-text' } }"
:popper="{ placement: 'bottom-start' }"
>
<UAvatar size="md" :src="state.avatar" :alt="state.name" />

<template #account>
<span class="truncate font-medium text-gray-900 dark:text-white">
{{ user?.username }}
</span>
</template>

<template #item="{ item }">
<span class="truncate">{{ item.label }}</span>

<UIcon
:name="item.icon"
class="ms-auto h-4 w-4 flex-shrink-0 text-gray-400 dark:text-gray-500"
/>
</template>
</UDropdown>
</div>
</ClientOnly>

<UModal v-model="isSettingsModalOpen">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"@0no-co/graphqlsp": "^1.7.1",
"@commitlint/config-conventional": "^19.1.0",
"@nuxt/eslint-config": "^0.2.0",
"@nuxt/fonts": "^0.4.0",
"@nuxt/fonts": "^0.5.1",
"@nuxt/ui": "^2.14.2",
"@nuxtjs/i18n": "^8.2.0",
"@pinia/nuxt": "^0.5.1",
Expand Down
23 changes: 15 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit eecad9e

Please sign in to comment.