aboutsummaryrefslogtreecommitdiff
path: root/src/components/font_control/font_control.js
diff options
context:
space:
mode:
authorMaxim Filippov <colixer@gmail.com>2018-12-17 02:39:37 +0300
committerMaxim Filippov <colixer@gmail.com>2018-12-17 02:39:37 +0300
commit2211c533ddf7a05723afb2e2a8664b9b49c9648d (patch)
treed5bcfbdb55536db01bc0bfda38991db8f159a3e9 /src/components/font_control/font_control.js
parent5fc0fe28e45882da0fab635e839a2977104d2f46 (diff)
parentada4bd0d9874d98213cf79ccd9f7cddda36d1b6c (diff)
Merge branch 'develop' into feature/new-user-routes
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
+ }
+ }
+ }
+}