2023-01-22 20:18:03 +00:00
|
|
|
import type { OldFontSize } from '~/composables/settings'
|
|
|
|
import { oldFontSizeMap } from '~/constants/options'
|
2023-01-14 09:34:53 +00:00
|
|
|
import { DEFAULT_FONT_SIZE } from '~/constants'
|
|
|
|
|
|
|
|
export default defineNuxtPlugin(() => {
|
|
|
|
const userSettings = useUserSettings()
|
2023-01-16 10:26:19 +00:00
|
|
|
const html = document.documentElement
|
2023-01-14 09:34:53 +00:00
|
|
|
watchEffect(() => {
|
2023-01-22 20:18:03 +00:00
|
|
|
const { fontSize } = userSettings.value
|
|
|
|
html.style.setProperty('--font-size', fontSize ? (oldFontSizeMap[fontSize as OldFontSize] ?? fontSize) : DEFAULT_FONT_SIZE)
|
2023-01-14 09:34:53 +00:00
|
|
|
})
|
2023-01-14 10:09:17 +00:00
|
|
|
watchEffect(() => {
|
2023-04-23 11:21:33 +01:00
|
|
|
html.classList.toggle('zen', userSettings.value.preferences.zenMode)
|
2023-01-14 10:09:17 +00:00
|
|
|
})
|
2023-01-16 10:26:19 +00:00
|
|
|
watchEffect(() => {
|
|
|
|
Object.entries(userSettings.value.themeColors || {}).forEach(([k, v]) => html.style.setProperty(k, v))
|
|
|
|
})
|
2023-01-14 09:34:53 +00:00
|
|
|
})
|