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