-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate ft-slider to the composition api (#6677)
* Migrate ft-slider to the composition api * Fix web webpack config * Use `useId` * Use `$t` * fix discrepancy
- Loading branch information
1 parent
19147e2
commit c436c5e
Showing
7 changed files
with
78 additions
and
91 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<template> | ||
<label | ||
class="pure-material-slider" | ||
:for="id" | ||
> | ||
<input | ||
:id="id" | ||
v-model.number="currentValue" | ||
:disabled="disabled" | ||
type="range" | ||
:min="minValue" | ||
:max="maxValue" | ||
:step="step" | ||
@change="change" | ||
> | ||
<span> | ||
{{ $t('Display Label', {label: label, value: displayLabel}) }} | ||
</span> | ||
</label> | ||
</template> | ||
|
||
<script setup> | ||
import { computed, ref } from 'vue' | ||
import { useId } from '../../composables/use-id-polyfill.js' | ||
const props = defineProps({ | ||
label: { | ||
type: String, | ||
required: true | ||
}, | ||
defaultValue: { | ||
type: Number, | ||
required: true | ||
}, | ||
minValue: { | ||
type: Number, | ||
required: true | ||
}, | ||
maxValue: { | ||
type: Number, | ||
required: true | ||
}, | ||
step: { | ||
type: Number, | ||
required: true | ||
}, | ||
valueExtension: { | ||
type: String, | ||
default: null | ||
}, | ||
disabled: { | ||
type: Boolean, | ||
default: false | ||
} | ||
}) | ||
const emit = defineEmits(['change']) | ||
const id = useId() | ||
const currentValue = ref(props.defaultValue) | ||
const displayLabel = computed(() => { | ||
if (props.valueExtension === null) { | ||
return currentValue.value | ||
} else { | ||
return `${currentValue.value}${props.valueExtension}` | ||
} | ||
}) | ||
function change() { | ||
emit('change', currentValue.value) | ||
} | ||
</script> | ||
<style scoped src="./FtSlider.css" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters