pleroma-fe/src/components/font_control/font_control.js

54 lines
1.2 KiB
JavaScript
Raw Normal View History

2026-01-08 17:26:52 +02:00
import Checkbox from 'src/components/checkbox/checkbox.vue'
import Popover from 'src/components/popover/popover.vue'
import { useInterfaceStore } from 'src/stores/interface'
import Select from '../select/select.vue'
2024-06-26 14:17:22 +03:00
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faExclamationTriangle,
2026-01-06 16:22:52 +02:00
faFont,
2026-01-06 16:23:17 +02:00
faKeyboard,
} from '@fortawesome/free-solid-svg-icons'
2024-06-26 14:17:22 +03:00
2026-01-06 16:22:52 +02:00
library.add(faExclamationTriangle, faKeyboard, faFont)
2024-06-26 14:17:22 +03:00
2018-12-11 00:56:15 +03:00
export default {
components: {
2024-06-26 14:17:22 +03:00
Select,
Checkbox,
2026-01-06 16:22:52 +02:00
Popover,
},
2026-01-06 16:22:52 +02:00
props: ['name', 'label', 'modelValue', 'fallback', 'options', 'no-inherit'],
mounted() {
2025-02-03 00:14:44 +02:00
useInterfaceStore().queryLocalFonts()
},
2022-03-27 14:16:23 +03:00
emits: ['update:modelValue'],
2026-01-06 16:22:52 +02:00
data() {
2018-12-11 00:56:15 +03:00
return {
2024-06-27 00:59:24 +03:00
manualEntry: false,
2018-12-11 00:56:15 +03:00
availableOptions: [
this.noInherit ? '' : 'inherit',
'serif',
'sans-serif',
2018-12-11 00:56:15 +03:00
'monospace',
2026-01-06 16:22:52 +02:00
...(this.options || []),
].filter((_) => _),
2018-12-11 00:56:15 +03:00
}
},
methods: {
2026-01-06 16:22:52 +02:00
toggleManualEntry() {
this.manualEntry = !this.manualEntry
2026-01-06 16:22:52 +02:00
},
2018-12-11 00:56:15 +03:00
},
computed: {
2026-01-06 16:22:52 +02:00
present() {
return typeof this.modelValue !== 'undefined'
2024-06-26 14:17:22 +03:00
},
2026-01-06 16:22:52 +02:00
localFontsList() {
2025-01-30 21:56:07 +02:00
return useInterfaceStore().localFonts
2018-12-11 00:56:15 +03:00
},
2026-01-06 16:22:52 +02:00
localFontsSize() {
2025-01-30 21:56:07 +02:00
return useInterfaceStore().localFonts?.length
2026-01-06 16:22:52 +02:00
},
},
2018-12-11 00:56:15 +03:00
}