logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git

font_control.js (1349B)


  1. import { set } from 'lodash'
  2. import Select from '../select/select.vue'
  3. export default {
  4. components: {
  5. Select
  6. },
  7. props: [
  8. 'name', 'label', 'modelValue', 'fallback', 'options', 'no-inherit'
  9. ],
  10. emits: ['update:modelValue'],
  11. data () {
  12. return {
  13. lValue: this.modelValue,
  14. availableOptions: [
  15. this.noInherit ? '' : 'inherit',
  16. 'custom',
  17. ...(this.options || []),
  18. 'serif',
  19. 'monospace',
  20. 'sans-serif'
  21. ].filter(_ => _)
  22. }
  23. },
  24. beforeUpdate () {
  25. this.lValue = this.modelValue
  26. },
  27. computed: {
  28. present () {
  29. return typeof this.lValue !== 'undefined'
  30. },
  31. dValue () {
  32. return this.lValue || this.fallback || {}
  33. },
  34. family: {
  35. get () {
  36. return this.dValue.family
  37. },
  38. set (v) {
  39. set(this.lValue, 'family', v)
  40. this.$emit('update:modelValue', this.lValue)
  41. }
  42. },
  43. isCustom () {
  44. return this.preset === 'custom'
  45. },
  46. preset: {
  47. get () {
  48. if (this.family === 'serif' ||
  49. this.family === 'sans-serif' ||
  50. this.family === 'monospace' ||
  51. this.family === 'inherit') {
  52. return this.family
  53. } else {
  54. return 'custom'
  55. }
  56. },
  57. set (v) {
  58. this.family = v === 'custom' ? '' : v
  59. }
  60. }
  61. }
  62. }