Profectus/src/components/fields/Slider.vue

41 lines
873 B
Vue
Raw Normal View History

2021-06-11 23:38:16 -05:00
<template>
<div class="field">
<span class="field-title" v-if="title">{{ title }}</span>
2022-01-13 22:25:47 -06:00
<Tooltip :display="`${value}`" :class="{ fullWidth: !title }">
<input type="range" v-model="value" :min="min" :max="max" />
</Tooltip>
</div>
2021-06-11 23:38:16 -05:00
</template>
2022-01-13 22:25:47 -06:00
<script setup lang="ts">
import { computed, toRefs, unref } from "vue";
import Tooltip from "../system/Tooltip.vue";
2022-01-13 22:25:47 -06:00
const props = toRefs(
defineProps<{
title?: string;
modelValue?: number;
min?: number;
max?: number;
}>()
);
const emit = defineEmits<{
(e: "update:modelValue", value: number): void;
}>();
const value = computed({
get() {
return unref(props.modelValue) || 0;
},
2022-01-13 22:25:47 -06:00
set(value: number) {
emit("update:modelValue", value);
}
});
2021-06-11 23:38:16 -05:00
</script>
<style scoped>
2021-06-22 07:56:11 -05:00
.fullWidth {
width: 100%;
2021-06-22 07:56:11 -05:00
}
2021-06-11 23:38:16 -05:00
</style>