feat: rename logics to logic

This commit is contained in:
Anthony Fu committed 2021-03-31 13:59:01 +08:00
1 parent 433aabe44c
commit ff4fa578fc
8 files changed
+192 -126

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { useI18n } from 'vue-i18n'
import { isDark, toggleDark } from '~/logics'
import { isDark, toggleDark } from '~/logic'
const { t, availableLocales, locale } = useI18n()
+2 -1
View File
@@ -1,3 +1,4 @@
import { useDark } from '@vueuse/core'
import { useDark, useToggle } from '@vueuse/core'
export const isDark = useDark()
export const toggleDark = useToggle(isDark)
File renamed without changes.
-25
View File
@@ -1,25 +0,0 @@
import { watch, computed } from 'vue'
import { usePreferredDark, useToggle } 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'
},
})
export const toggleDark = useToggle(isDark)
watch(
isDark,
v => typeof document !== 'undefined' && document.documentElement.classList.toggle('dark', v),
{ immediate: true },
)
-4
View File
@@ -1,4 +0,0 @@
import { Ref } from 'vue'
import { useStorage } from '@vueuse/core'
export const colorSchema = useStorage('color-schema', 'auto') as Ref<'auto' | 'dark' | 'light'>
+2 -2
View File
@@ -10,11 +10,11 @@ Check out [`vite-plugin-pages`](https://github.com/hannoeru/vite-plugin-pages) f
For example, instead of having
```ts
import { isDark } from '../../../../logics'
import { isDark } from '../../../../logic'
```
now, you can use
```ts
import { isDark } from '~/logics'
import { isDark } from '~/logic'
```