Files
speckle-server/packages/frontend-2/lib/core/composables/theme.ts
T
Kristaps Fabians Geikins f80a7189a0 chore(fe2): upgrade to nuxt 3.8.2 (#1887)
* chore(fe2): upgrade to nuxt 3.8.2

* fix tailwind-theme build

* readme update

* removing storybook from fe2 :(

* fix(fe2): codegen schema url resolution
2023-11-29 10:22:17 +02:00

26 lines
671 B
TypeScript

import type { Optional } from '@speckle/shared'
import { useSynchronizedCookie } from '~~/lib/common/composables/reactiveCookie'
import { CookieKeys } from '~~/lib/common/helpers/constants'
export enum AppTheme {
Light = 'light',
Dark = 'dark'
}
/**
* Use this to read & write theme
*/
export function useTheme() {
const themeCookie = useSynchronizedCookie<Optional<AppTheme>>(CookieKeys.Theme)
const isDarkTheme = computed(() => themeCookie.value === AppTheme.Dark)
const isLightTheme = computed(() => !isDarkTheme.value)
return {
setTheme: (newTheme: AppTheme) => {
themeCookie.value = newTheme
},
isDarkTheme,
isLightTheme
}
}