diff options
| author | HJ <spam@hjkos.com> | 2018-12-11 20:35:19 +0000 |
|---|---|---|
| committer | HJ <spam@hjkos.com> | 2018-12-11 20:35:19 +0000 |
| commit | a8acba8cb2c639a3de3764df4226960458f996b8 (patch) | |
| tree | 50c4d353576cc419eeea4f45c4497309222cf360 /src/components/font_control/font_control.js | |
| parent | fb5261b926adfb5b9bbe1bf55e36fe8b5f4eb57f (diff) | |
| parent | 8fcc4c67667b0951d6c0d28cec320bd4b2f8f107 (diff) | |
Merge branch 'feature/theming2' into 'develop'
Themes v2
See merge request pleroma/pleroma-fe!377
Diffstat (limited to 'src/components/font_control/font_control.js')
| -rw-r--r-- | src/components/font_control/font_control.js | 58 |
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 + } + } + } +} |
