pleroma-fe/src/components/font_control/font_control.vue

146 lines
3.8 KiB
Vue
Raw Normal View History

2018-11-25 21:48:16 +03:00
<template>
2019-07-05 10:17:44 +03:00
<div
2024-06-26 14:17:22 +03:00
class="font-control"
2019-07-05 10:17:44 +03:00
:class="{ custom: isCustom }"
>
<label
2023-03-03 23:38:56 -05:00
:id="name + '-label'"
2019-07-05 10:17:44 +03:00
:for="preset === 'custom' ? name : name + '-font-switcher'"
class="label"
>
{{ label }}
</label>
{{ ' ' }}
<Checkbox
v-if="typeof fallback !== 'undefined'"
:id="name + '-o'"
:modelValue="present"
@change="$emit('update:modelValue', typeof modelValue === 'undefined' ? fallback : undefined)"
>
{{ $t('settings.style.themes3.define') }}
</Checkbox>
<p v-if="modelValue?.family">
<label
v-if="manualEntry"
:id="name + '-label'"
:for="preset === 'custom' ? name : name + '-font-switcher'"
class="label"
>
<i18n-t
keypath="settings.style.themes3.font.entry"
tag="span"
>
<template #fontFamily>
<code>font-family</code>
</template>
</i18n-t>
</label>
<label
v-else
:id="name + '-label'"
:for="preset === 'custom' ? name : name + '-font-switcher'"
class="label"
>
{{ $t('settings.style.themes3.font.select') }}
</label>
{{ ' ' }}
<span
v-if="manualEntry"
class="btn-group"
>
<button
class="btn button-default"
@click="toggleManualEntry"
:title="$t('settings.style.themes3.font.lookup_local_fonts')"
>
<FAIcon
fixed-width
icon="font"
/>
</button>
<input
:id="name"
:model-value="modelValue.family"
class="input custom-font"
type="text"
@update:modelValue="$emit('update:modelValue', { ...(modelValue || {}), family: $event.target.value })"
>
</span>
<span
v-else
class="btn-group"
>
<button
class="btn button-default"
@click="toggleManualEntry"
:title="$t('settings.style.themes3.font.enter_manually')"
>
<FAIcon
fixed-width
icon="keyboard"
/>
</button>
<Select
:id="name + '-local-font-switcher'"
:model-value="modelValue?.family"
class="custom-font"
@update:modelValue="v => $emit('update:modelValue', { ...(modelValue || {}), family: v })"
>
<optgroup
:label="$t('settings.style.themes3.font.group-builtin')"
>
<option
v-for="option in availableOptions"
:key="option"
:value="option"
:style="{ fontFamily: option === 'inherit' ? null : option }"
>
{{ $t('settings.style.themes3.font.builtin.' + option) }}
</option>
</optgroup>
<optgroup
v-if="localFontsSize > 0"
:label="$t('settings.style.themes3.font.group-local')"
>
<option
v-for="option in localFontsList"
:key="option"
:value="option"
:style="{ fontFamily: option }"
>
{{ option }}
</option>
</optgroup>
<optgroup
v-else
:label="$t('settings.style.themes3.font.group-local')"
>
<option disabled>
{{ $t('settings.style.themes3.font.local-unavailable1') }}
</option>
<option disabled>
{{ $t('settings.style.themes3.font.local-unavailable2') }}
</option>
</optgroup>
</Select>
</span>
2024-06-26 14:17:22 +03:00
</p>
2019-07-05 10:17:44 +03:00
</div>
2018-11-25 21:48:16 +03:00
</template>
2022-07-31 12:35:48 +03:00
<script src="./font_control.js"></script>
2018-11-25 21:48:16 +03:00
<style lang="scss">
.font-control {
.custom-font {
min-width: 20em;
max-width: 20em;
2018-11-25 21:48:16 +03:00
}
2024-06-26 14:17:22 +03:00
}
2023-01-09 13:02:16 -05:00
2024-06-26 14:17:22 +03:00
.invalid-tooltip {
margin: 0.5em 1em;
min-width: 10em;
text-align: center;
2018-11-25 21:48:16 +03:00
}
</style>