aboutsummaryrefslogtreecommitdiff
path: root/src/components/font_control/font_control.js
diff options
context:
space:
mode:
authorRinpatch <rinpatch@sdf.org>2018-12-13 17:22:19 +0300
committerRinpatch <rinpatch@sdf.org>2018-12-13 17:22:19 +0300
commit6de4dcc7c99e14552303e5eee7dac31dd5e58e2e (patch)
tree668904f3dba16ab39f683345b2e979e57696db94 /src/components/font_control/font_control.js
parent48edc0c8fcc6c63e432c9b6d78f14af086b56900 (diff)
parent8e4777ccc6bf72b56a0905ca491c8e0e97fb73cf (diff)
Resolve merge conflict
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
+ }
+ }
+ }
+}