2018-11-25 10:48:16 -08:00
|
|
|
<template>
|
2018-11-25 13:19:28 -08:00
|
|
|
<div class="font-control style-control" :class="{ custom: isCustom }">
|
2018-11-25 10:48:16 -08:00
|
|
|
<label :for="preset === 'custom' ? name : name + '-font-switcher'" class="label">
|
|
|
|
{{label}}
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
v-if="typeof fallback !== 'undefined'"
|
|
|
|
class="opt exlcude-disabled"
|
|
|
|
type="checkbox"
|
|
|
|
:id="name + '-o'"
|
|
|
|
:checked="present"
|
|
|
|
@input="$emit('input', typeof value === 'undefined' ? fallback : undefined)">
|
|
|
|
<label v-if="typeof fallback !== 'undefined'" class="opt-l" :for="name + '-o'"></label>
|
|
|
|
<label :for="name + '-font-switcher'" class="select" :disabled="!present">
|
|
|
|
<select
|
|
|
|
:disabled="!present"
|
|
|
|
v-model="preset"
|
|
|
|
class="font-switcher"
|
2018-11-25 13:19:28 -08:00
|
|
|
:id="name + '-font-switcher'">
|
2018-11-25 11:39:06 -08:00
|
|
|
<option v-for="option in availableOptions" :value="option">
|
2018-11-25 13:19:28 -08:00
|
|
|
{{ option === 'custom' ? $t('settings.style.fonts.custom') : option }}
|
2018-11-25 10:48:16 -08:00
|
|
|
</option>
|
|
|
|
</select>
|
|
|
|
<i class="icon-down-open"/>
|
|
|
|
</label>
|
|
|
|
<input
|
2018-11-25 13:19:28 -08:00
|
|
|
v-if="isCustom"
|
2018-11-25 10:48:16 -08:00
|
|
|
class="custom-font"
|
|
|
|
type="text"
|
2018-11-25 13:19:28 -08:00
|
|
|
:id="name"
|
2018-11-25 10:48:16 -08:00
|
|
|
v-model="family">
|
|
|
|
</div>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import { set } from 'vue'
|
|
|
|
|
|
|
|
export default {
|
|
|
|
props: [
|
2018-11-25 11:39:06 -08:00
|
|
|
'name', 'label', 'value', 'fallback', 'options', 'no-inherit'
|
2018-11-25 10:48:16 -08:00
|
|
|
],
|
|
|
|
data () {
|
|
|
|
return {
|
2018-11-25 11:39:06 -08:00
|
|
|
lValue: this.value,
|
|
|
|
availableOptions: [
|
|
|
|
this.noInherit ? '' : 'inherit',
|
|
|
|
'custom',
|
|
|
|
...(this.options || []),
|
|
|
|
'serif',
|
|
|
|
'monospace',
|
|
|
|
'sans-serif'
|
|
|
|
].filter(_ => _)
|
2018-11-25 10:48:16 -08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
},
|
2018-11-25 13:19:28 -08:00
|
|
|
isCustom () {
|
|
|
|
return this.preset === 'custom'
|
|
|
|
},
|
2018-11-25 10:48:16 -08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@import '../../_variables.scss';
|
|
|
|
.font-control {
|
|
|
|
input.custom-font {
|
|
|
|
min-width: 10em;
|
|
|
|
}
|
2018-11-25 13:19:28 -08:00
|
|
|
&.custom {
|
|
|
|
.select {
|
|
|
|
border-top-right-radius: 0;
|
|
|
|
border-bottom-right-radius: 0;
|
|
|
|
}
|
|
|
|
.custom-font {
|
|
|
|
border-top-left-radius: 0;
|
|
|
|
border-bottom-left-radius: 0;
|
|
|
|
}
|
|
|
|
}
|
2018-11-25 10:48:16 -08:00
|
|
|
}
|
|
|
|
</style>
|