2022-12-28 08:03:50 +09:00
|
|
|
<script lang="ts" setup>
|
2022-12-30 05:08:50 +09:00
|
|
|
import { DEFAULT_FONT_SIZE } from '~/constants'
|
2023-01-13 02:52:52 +09:00
|
|
|
import type { FontSize } from '~/composables/settings'
|
|
|
|
|
|
|
|
const userSettings = useUserSettings()
|
2022-12-28 08:03:50 +09:00
|
|
|
|
2023-08-02 19:28:18 +09:00
|
|
|
const sizes = (Array.from({ length: 11 })).fill(0).map((x, i) => `${10 + i}px`) as FontSize[]
|
2023-01-23 05:18:03 +09:00
|
|
|
|
2023-03-31 04:01:24 +09:00
|
|
|
function setFontSize(e: Event) {
|
2023-01-23 05:18:03 +09:00
|
|
|
if (e.target && 'valueAsNumber' in e.target)
|
|
|
|
userSettings.value.fontSize = sizes[e.target.valueAsNumber as number]
|
|
|
|
}
|
2022-12-28 08:03:50 +09:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-04-15 03:06:25 +09:00
|
|
|
<section space-y-2>
|
|
|
|
<h2 id="interface-fs" font-medium>
|
|
|
|
{{ $t('settings.interface.font_size') }}
|
|
|
|
</h2>
|
|
|
|
<div flex items-center space-x-4 select-settings>
|
|
|
|
<span text-xs text-secondary>Aa</span>
|
|
|
|
<div flex-1 relative flex items-center>
|
|
|
|
<input
|
|
|
|
aria-labelledby="interface-fs"
|
|
|
|
:value="sizes.indexOf(userSettings.fontSize)"
|
|
|
|
:aria-valuetext="`${userSettings.fontSize}${userSettings.fontSize === DEFAULT_FONT_SIZE ? ` ${$t('settings.interface.default')}` : ''}`"
|
|
|
|
:min="0"
|
|
|
|
:max="sizes.length - 1"
|
|
|
|
:step="1"
|
|
|
|
type="range"
|
|
|
|
focus:outline-none
|
|
|
|
appearance-none bg-transparent
|
|
|
|
w-full cursor-pointer
|
|
|
|
@change="setFontSize"
|
2023-01-23 05:18:03 +09:00
|
|
|
>
|
2024-04-15 03:06:25 +09:00
|
|
|
<div flex items-center justify-between absolute w-full pointer-events-none>
|
2023-01-23 05:18:03 +09:00
|
|
|
<div
|
2024-04-15 03:06:25 +09:00
|
|
|
v-for="i in sizes.length" :key="i"
|
|
|
|
class="container-marker"
|
|
|
|
h-3 w-3
|
|
|
|
rounded-full bg-secondary-light
|
|
|
|
relative
|
|
|
|
>
|
|
|
|
<div
|
|
|
|
v-if="(sizes.indexOf(userSettings.fontSize)) === i - 1"
|
|
|
|
absolute rounded-full class="-top-1 -left-1"
|
|
|
|
bg-primary h-5 w-5
|
|
|
|
/>
|
|
|
|
</div>
|
2023-01-23 05:18:03 +09:00
|
|
|
</div>
|
|
|
|
</div>
|
2024-04-15 03:06:25 +09:00
|
|
|
<span text-xl text-secondary>Aa</span>
|
2023-01-23 05:18:03 +09:00
|
|
|
</div>
|
2024-04-15 03:06:25 +09:00
|
|
|
</section>
|
2022-12-28 08:03:50 +09:00
|
|
|
</template>
|
2023-01-23 05:18:03 +09:00
|
|
|
|
|
|
|
<style>
|
2024-04-13 02:19:37 +09:00
|
|
|
input:focus + div .container-marker:has(> div)::before {
|
|
|
|
content: '';
|
|
|
|
position: absolute;
|
|
|
|
top: 50%;
|
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
|
|
|
width: 2rem;
|
|
|
|
height: 2rem;
|
|
|
|
border: 2px solid var(--c-primary);
|
|
|
|
border-radius: 50%;
|
|
|
|
}
|
2023-01-23 05:18:03 +09:00
|
|
|
input[type=range]::-webkit-slider-runnable-track {
|
|
|
|
--at-apply: bg-secondary-light rounded-full h1 op60;
|
|
|
|
}
|
2024-04-15 03:06:25 +09:00
|
|
|
input[type=range]:focus::-webkit-slider-runnable-track {
|
2023-01-23 05:18:03 +09:00
|
|
|
--at-apply: outline-2 outline-red;
|
|
|
|
}
|
|
|
|
input[type=range]::-webkit-slider-thumb {
|
|
|
|
--at-apply: w3 h3 bg-primary -mt-1 outline outline-3 outline-primary rounded-full cursor-pointer appearance-none;
|
|
|
|
}
|
|
|
|
input[type=range]::-moz-range-track {
|
|
|
|
--at-apply: bg-secondary-light rounded-full h1 op60;
|
|
|
|
}
|
|
|
|
input[type=range]:focus::-moz-range-track {
|
|
|
|
--at-apply: outline-2 outline-red;
|
|
|
|
}
|
|
|
|
input[type=range]::-moz-range-thumb {
|
|
|
|
--at-apply: w3 h3 bg-primary -mt-1 outline outline-3 outline-primary rounded-full cursor-pointer appearance-none border-none;
|
|
|
|
}
|
|
|
|
</style>
|