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

67 行
1.6 KiB
Vue
Raw 通常表示 履歴

2018-11-21 09:14:59 +09:00
<template>
2019-07-05 16:17:44 +09:00
<div
class="range-control style-control"
:class="{ disabled: !present || disabled }"
>
<label
2023-03-04 13:38:56 +09:00
:id="name + '-label'"
2019-07-05 16:17:44 +09:00
:for="name"
class="label"
>
{{ label }}
</label>
<input
v-if="typeof fallback !== 'undefined'"
:id="name + '-o'"
2023-03-04 13:38:56 +09:00
:aria-labelledby="name + '-label'"
class="opt visible-for-screenreader-only"
2019-07-05 16:17:44 +09:00
type="checkbox"
2022-03-27 19:28:59 +09:00
:checked="present"
@change="$emit('update:modelValue', !present ? fallback : undefined)"
2019-07-05 16:17:44 +09:00
>
<label
v-if="typeof fallback !== 'undefined'"
class="opt-l"
:for="name + '-o'"
2023-03-04 13:38:56 +09:00
:aria-hidden="true"
2019-07-05 16:17:44 +09:00
/>
<input
:id="name"
class="input-number"
type="range"
2022-03-27 19:28:59 +09:00
:value="modelValue || fallback"
2019-07-05 16:17:44 +09:00
:disabled="!present || disabled"
:max="max || hardMax || 100"
:min="min || hardMin || 0"
:step="step || 1"
2021-04-25 19:23:16 +09:00
@input="$emit('update:modelValue', $event.target.value)"
2019-07-05 16:17:44 +09:00
>
<input
2023-03-04 13:38:56 +09:00
:id="name + '-numeric'"
2019-07-05 16:17:44 +09:00
class="input-number"
type="number"
2023-03-04 13:38:56 +09:00
:aria-labelledby="name + '-label'"
2022-03-27 19:28:59 +09:00
:value="modelValue || fallback"
2019-07-05 16:17:44 +09:00
:disabled="!present || disabled"
:max="hardMax"
:min="hardMin"
:step="step || 1"
2021-04-25 19:23:16 +09:00
@input="$emit('update:modelValue', $event.target.value)"
2019-07-05 16:17:44 +09:00
>
</div>
2018-11-21 09:14:59 +09:00
</template>
<script>
export default {
props: [
2022-03-27 19:28:59 +09:00
'name', 'modelValue', 'fallback', 'disabled', 'label', 'max', 'min', 'step', 'hardMin', 'hardMax'
2018-11-21 09:14:59 +09:00
],
2022-03-27 19:28:59 +09:00
emits: ['update:modelValue'],
2018-11-21 09:14:59 +09:00
computed: {
present () {
2022-03-27 19:28:59 +09:00
return typeof this.modelValue !== 'undefined'
2018-11-21 09:14:59 +09:00
}
}
}
</script>