forked from FreeTubeApp/FreeTube
-
Notifications
You must be signed in to change notification settings - Fork 5
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
- Loading branch information
1 parent
47d4103
commit f629f2f
Showing
7 changed files
with
81 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,78 @@ | ||
<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 { randomUUID } from 'crypto' | ||
import { useI18n } from '../../composables/use-i18n-polyfill' | ||
const { t } = useI18n() | ||
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 = randomUUID() | ||
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