Skip to content

Commit

Permalink
feat(BaseTabSlider)!: rename selected prop to modelValue to allow v-m…
Browse files Browse the repository at this point in the history
…odel
  • Loading branch information
stafyniaksacha committed Aug 28, 2023
1 parent d20e934 commit fda6395
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions .playground/pages/tests/content/shapes.vue
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ const app = useAppConfig()
></BaseTabSlider>
<BaseTabSlider
shape="rounded"
:model-value="'rounded2'"
:tabs="[{ value: 'rounded' }, { value: 'rounded2' }]"
></BaseTabSlider>
<BaseTabSlider
Expand Down
12 changes: 6 additions & 6 deletions components/base/BaseTabSlider.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const props = withDefaults(
/**
* The value of the currently selected tab.
*/
selected?: string
modelValue?: string
/**
* Controls the alignment of the tabs. Can be 'start', 'center', or 'end'.
*/
Expand All @@ -32,14 +32,14 @@ const props = withDefaults(
condensed?: boolean
}>(),
{
selected: undefined,
modelValue: undefined,
justify: undefined,
size: 'md',
shape: undefined,
},
)
const emit = defineEmits<{
(event: 'update:selected', value?: string): void
(event: 'update:modelValue', value?: string): void
}>()
const appConfig = useAppConfig()
const shape = computed(
Expand Down Expand Up @@ -69,21 +69,21 @@ const lengthStyle = computed(() =>
)
const activeValue = ref<string | undefined>(
props.selected ?? props.tabs[0]?.value,
props.modelValue ?? props.tabs[0]?.value,
)
function toggle(value: string) {
activeValue.value = value
}
watch(
() => props.selected,
() => props.modelValue,
(value) => {
activeValue.value = value
},
)
watch(activeValue, (value) => {
emit('update:selected', value)
emit('update:modelValue', value)
})
</script>

Expand Down

0 comments on commit fda6395

Please sign in to comment.