aboutsummaryrefslogtreecommitdiff
path: root/src/components/font_control/font_control.js
blob: 08d0907e4bbe74891080237a1b8affb485f00a17 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Select from '../select/select.vue'
import Checkbox from 'src/components/checkbox/checkbox.vue'
import Popover from 'src/components/popover/popover.vue'

import { library } from '@fortawesome/fontawesome-svg-core'
import {
  faExclamationTriangle,
  faKeyboard,
  faFont
} from '@fortawesome/free-solid-svg-icons'

library.add(
  faExclamationTriangle,
  faKeyboard,
  faFont
)

export default {
  components: {
    Select,
    Checkbox,
    Popover
  },
  props: [
    'name', 'label', 'modelValue', 'fallback', 'options', 'no-inherit'
  ],
  mounted () {
    this.$store.dispatch('queryLocalFonts')
  },
  emits: ['update:modelValue'],
  data () {
    return {
      manualEntry: false,
      availableOptions: [
        this.noInherit ? '' : 'inherit',
        'serif',
        'sans-serif',
        'monospace',
        ...(this.options || [])
      ].filter(_ => _)
    }
  },
  methods: {
    toggleManualEntry () {
      this.manualEntry = !this.manualEntry
    }
  },
  computed: {
    present () {
      return typeof this.modelValue !== 'undefined'
    },
    localFontsList () {
      return this.$store.state.interface.localFonts?.values()
    },
    localFontsSize () {
      return this.$store.state.interface.localFonts?.size
    }
  }
}