aboutsummaryrefslogtreecommitdiff
path: root/src/components/font_control/font_control.js
diff options
context:
space:
mode:
authorEgor Kislitsyn <egor@kislitsyn.com>2018-12-13 18:22:15 +0700
committerEgor Kislitsyn <egor@kislitsyn.com>2018-12-13 18:22:15 +0700
commita8521fc8d99ee7ee5142e2c7c642eee0fc14ed93 (patch)
tree53e98662ef34b8bccc845f627c125528c1c1436c /src/components/font_control/font_control.js
parentb3455649c53034e01725977260e69cff59c47e87 (diff)
parente443716bcd616ad61efae161624dd970841a935c (diff)
Merge commit 'e443716bcd616ad61efae161624dd970841a935c' into feature/push-subscriptions
# Conflicts: # src/i18n/en.json # src/modules/interface.js # src/modules/users.js # yarn.lock
Diffstat (limited to 'src/components/font_control/font_control.js')
-rw-r--r--src/components/font_control/font_control.js58
1 files changed, 58 insertions, 0 deletions
diff --git a/src/components/font_control/font_control.js b/src/components/font_control/font_control.js
new file mode 100644
index 00000000..8e2b0e45
--- /dev/null
+++ b/src/components/font_control/font_control.js
@@ -0,0 +1,58 @@
+import { set } from 'vue'
+
+export default {
+ props: [
+ 'name', 'label', 'value', 'fallback', 'options', 'no-inherit'
+ ],
+ data () {
+ return {
+ lValue: this.value,
+ availableOptions: [
+ this.noInherit ? '' : 'inherit',
+ 'custom',
+ ...(this.options || []),
+ 'serif',
+ 'monospace',
+ 'sans-serif'
+ ].filter(_ => _)
+ }
+ },
+ beforeUpdate () {
+ this.lValue = this.value
+ },
+ computed: {
+ present () {
+ return typeof this.lValue !== 'undefined'
+ },
+ dValue () {
+ return this.lValue || this.fallback || {}
+ },
+ family: {
+ get () {
+ return this.dValue.family
+ },
+ set (v) {
+ set(this.lValue, 'family', v)
+ this.$emit('input', this.lValue)
+ }
+ },
+ isCustom () {
+ return this.preset === 'custom'
+ },
+ preset: {
+ get () {
+ if (this.family === 'serif' ||
+ this.family === 'sans-serif' ||
+ this.family === 'monospace' ||
+ this.family === 'inherit') {
+ return this.family
+ } else {
+ return 'custom'
+ }
+ },
+ set (v) {
+ this.family = v === 'custom' ? '' : v
+ }
+ }
+ }
+}