feat: range of font size (#1376)
This commit is contained in:
parent
85be61a316
commit
1a577343da
20 changed files with 86 additions and 102 deletions
|
@ -1,11 +1,13 @@
|
|||
import { fontSizeMap } from '~/constants/options'
|
||||
import type { OldFontSize } from '~/composables/settings'
|
||||
import { oldFontSizeMap } from '~/constants/options'
|
||||
import { DEFAULT_FONT_SIZE } from '~/constants'
|
||||
|
||||
export default defineNuxtPlugin(() => {
|
||||
const userSettings = useUserSettings()
|
||||
const html = document.documentElement
|
||||
watchEffect(() => {
|
||||
html.style.setProperty('--font-size', fontSizeMap[userSettings.value.fontSize || DEFAULT_FONT_SIZE])
|
||||
const { fontSize } = userSettings.value
|
||||
html.style.setProperty('--font-size', fontSize ? (oldFontSizeMap[fontSize as OldFontSize] ?? fontSize) : DEFAULT_FONT_SIZE)
|
||||
})
|
||||
watchEffect(() => {
|
||||
html.classList.toggle('zen', userSettings.value.zenMode)
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { STORAGE_KEY_CURRENT_USER_HANDLE, STORAGE_KEY_SETTINGS } from '~/constants'
|
||||
import { fontSizeMap } from '~/constants/options'
|
||||
import { oldFontSizeMap } from '~/constants/options'
|
||||
|
||||
/**
|
||||
* Injecting scripts before renders
|
||||
|
@ -19,8 +19,8 @@ export default defineNuxtPlugin(() => {
|
|||
${process.dev ? 'console.log({ settings })' : ''}
|
||||
|
||||
if (settings.fontSize) {
|
||||
const fontSizeMap = ${JSON.stringify(fontSizeMap)}
|
||||
html.style.setProperty('--font-size', fontSizeMap[settings.fontSize])
|
||||
const oldFontSizeMap = ${JSON.stringify(oldFontSizeMap)}
|
||||
html.style.setProperty('--font-size', oldFontSizeMap[settings.fontSize] || settings.fontSize)
|
||||
}
|
||||
if (settings.language) {
|
||||
html.setAttribute('lang', settings.language)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue