aboutsummaryrefslogtreecommitdiff
path: root/src/components/font_control/font_control.vue
blob: f1b126be095d1e98aec76d362b307798d8d6d37b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<template>
  <div
    class="font-control"
    :class="{ custom: isCustom }"
  >
    <label
      :id="name + '-label'"
      :for="preset === 'custom' ? name : name + '-font-switcher'"
      class="label"
    >
      {{ label }}
    </label>
    <p>
      <Select
        :id="name + '-font-switcher'"
        v-model="preset"
        :disabled="!present"
        class="font-switcher"
      >
        <option
          v-for="option in availableOptions"
          :key="option"
          :value="option"
        >
          {{ $t('settings.style.themes3.font.' + option) }}
        </option>
      </Select>
      {{ ' ' }}
      <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>
    <p v-if="isCustom">
      <label
        v-if="fontsList !== null && !manualEntry"
        :id="name + '-label'"
        :for="preset === 'custom' ? name : name + '-font-switcher'"
        class="label"
      >
        {{ $t('settings.style.themes3.font.select') }}
      </label>
      <label
        v-else
        :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>
      {{ ' ' }}
      <span class="btn-group">
        <button
          v-if="fontsListCapable && (fontsList === null || manualEntry)"
          class="btn button-default"
          @click="lookupLocalFonts"
          :title="$t('settings.style.themes3.font.lookup_local_fonts')"
        >
          <FAIcon
            fixed-width
            icon="font"
          />
        </button>
          <input
            v-if="fontsLists === null || manualEntry"
            :id="name"
            v-model="familyCustom"
            class="input custom-font"
            type="text"
          >
      </span>
      <span class="btn-group">
        <button
          v-if="fontsList !== null && !manualEntry"
          class="btn button-default"
          @click="toggleManualEntry"
          :title="$t('settings.style.themes3.font.enter_manually')"
        >
          <FAIcon
            fixed-width
            icon="keyboard"
          />
        </button>
        <Select
          v-if="fontsList !== null && !manualEntry"
          :id="name + '-local-font-switcher'"
          v-model="familyCustom"
          class="custom-font"
        >
          <option
            v-for="option in fontsList.values()"
            :key="option"
            :value="option"
            :style="{ fontFamily: option }"
          >
            {{ option }}
          </option>
        </Select>
      </span>
      <span
        v-if="invalidCustom"
        class="InvalidIndicator"
      >
        <Popover
          trigger="hover"
          :trigger-attrs="{ 'aria-label': $t('settings.style.themes3.font.invalid_custom_reserved') }"
        >
          <template #trigger>
            &nbsp;
            <FAIcon icon="exclamation-triangle" />
          </template>
          <template #content>
            <div class="invalid-tooltip">
              {{ $t('settings.style.themes3.font.invalid_custom_reserved') }}
            </div>
          </template>
        </Popover>
      </span>
    </p>
  </div>
</template>

<script src="./font_control.js"></script>

<style lang="scss">
.font-control {
  .custom-font {
    min-width: 20em;
    max-width: 20em;
  }
}

.invalid-tooltip {
  margin: 0.5em 1em;
  min-width: 10em;
  text-align: center;
}
</style>