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

67 lines
1.6 KiB
Vue
Raw Normal View History

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