feat: tailwind 2 + script setup!

This commit is contained in:
Anthony Fu committed 2020-11-28 14:14:36 +08:00
1 parent f179e3e40b
commit 14b6a74360
21 files changed
+526 -455

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
import { watch, computed } from 'vue'
import { usePreferredDark } from '@vueuse/core'
import { colorSchema } from './store'
const preferredDark = usePreferredDark()
export const isDark = computed({
get() {
return colorSchema.value === 'auto' ? preferredDark.value : colorSchema.value === 'dark'
},
set(v: boolean) {
if (v === preferredDark.value)
colorSchema.value = 'auto'
else
colorSchema.value = v ? 'dark' : 'light'
},
})
watch(
isDark,
v => document.documentElement.classList.toggle('dark', v),
{ immediate: true },
)
+2
View File
@@ -0,0 +1,2 @@
export * from './dark'
export * from './store'
+4
View File
@@ -0,0 +1,4 @@
import { Ref } from 'vue'
import { useStorage } from '@vueuse/core'
export const colorSchema = useStorage('color-schema', 'auto') as Ref<'auto' | 'dark' | 'light'>