mirror of
https://github.com/DavidHDev/vue-bits.git
synced 2026-03-07 14:39:30 -07:00
Added defineModel support for PreviewSelect component
This commit is contained in:
@@ -3,8 +3,7 @@
|
|||||||
<span class="select-label">{{ title }}</span>
|
<span class="select-label">{{ title }}</span>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
:model-value="modelValue"
|
v-model="model"
|
||||||
@update:model-value="handleSelectChange"
|
|
||||||
:options="options"
|
:options="options"
|
||||||
v-bind="selectAttributes"
|
v-bind="selectAttributes"
|
||||||
:placeholder="placeholder"
|
:placeholder="placeholder"
|
||||||
@@ -25,7 +24,6 @@ interface Option {
|
|||||||
|
|
||||||
const props = defineProps<{
|
const props = defineProps<{
|
||||||
title: string;
|
title: string;
|
||||||
modelValue: string | number;
|
|
||||||
options: Option[] | string[] | number[];
|
options: Option[] | string[] | number[];
|
||||||
optionLabel?: string;
|
optionLabel?: string;
|
||||||
optionValue?: string;
|
optionValue?: string;
|
||||||
@@ -33,13 +31,7 @@ const props = defineProps<{
|
|||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
const model = defineModel<string | number>();
|
||||||
'update:modelValue': [value: string | number];
|
|
||||||
}>();
|
|
||||||
|
|
||||||
const handleSelectChange = (value: string | number) => {
|
|
||||||
emit('update:modelValue', value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const isObjectArray = computed(() => {
|
const isObjectArray = computed(() => {
|
||||||
return props.options.length > 0 && typeof props.options[0] === 'object';
|
return props.options.length > 0 && typeof props.options[0] === 'object';
|
||||||
|
|||||||
@@ -25,29 +25,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewSelect
|
<PreviewSelect title="Animation Direction" v-model="direction" :options="directionOptions" />
|
||||||
title="Animation Direction"
|
|
||||||
v-model="direction"
|
|
||||||
:options="directionOptions"
|
|
||||||
@update:model-value="
|
|
||||||
val => {
|
|
||||||
direction = val as 'vertical' | 'horizontal';
|
|
||||||
forceRerender();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<PreviewSelect
|
<PreviewSelect title="Easing Function" v-model="ease" :options="easeOptions" />
|
||||||
title="Easing Function"
|
|
||||||
v-model="ease"
|
|
||||||
:options="easeOptions"
|
|
||||||
@update:model-value="
|
|
||||||
val => {
|
|
||||||
ease = val as string;
|
|
||||||
forceRerender();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
title="Distance"
|
title="Distance"
|
||||||
@@ -126,7 +106,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref, watch } from 'vue';
|
||||||
import TabbedLayout from '../../components/common/TabbedLayout.vue';
|
import TabbedLayout from '../../components/common/TabbedLayout.vue';
|
||||||
import PropTable from '../../components/common/PropTable.vue';
|
import PropTable from '../../components/common/PropTable.vue';
|
||||||
import Dependencies from '../../components/code/Dependencies.vue';
|
import Dependencies from '../../components/code/Dependencies.vue';
|
||||||
@@ -233,6 +213,10 @@ const propData = [
|
|||||||
description: 'Additional CSS classes for styling.'
|
description: 'Additional CSS classes for styling.'
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
watch([direction, ease], () => {
|
||||||
|
forceRerender();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
|
|||||||
@@ -52,7 +52,7 @@
|
|||||||
|
|
||||||
<PreviewColor title="Text Color" v-model="textColor" />
|
<PreviewColor title="Text Color" v-model="textColor" />
|
||||||
|
|
||||||
<PreviewSelect title="Font" v-model="font" :options="fontOptions" @update:model-value="forceRerender" />
|
<PreviewSelect title="Font" v-model="font" :options="fontOptions" />
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
|
|||||||
@@ -37,7 +37,6 @@
|
|||||||
{ label: 'Center', value: 'center' },
|
{ label: 'Center', value: 'center' },
|
||||||
{ label: 'Random', value: 'random' }
|
{ label: 'Random', value: 'random' }
|
||||||
]"
|
]"
|
||||||
@update:model-value="forceRerender"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
|
|||||||
@@ -10,12 +10,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewSelect
|
<PreviewSelect title="Animation Variant" :options="variantOptions" v-model="selectedVariant" />
|
||||||
title="Animation Variant"
|
|
||||||
:options="variantOptions"
|
|
||||||
v-model="selectedVariant"
|
|
||||||
@update:model-value="forceRerender"
|
|
||||||
/>
|
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
@@ -44,7 +39,7 @@ import { pixelCard } from '@/constants/code/Components/pixelCardCode';
|
|||||||
import { useForceRerender } from '@/composables/useForceRerender';
|
import { useForceRerender } from '@/composables/useForceRerender';
|
||||||
|
|
||||||
const selectedVariant = ref<'default' | 'blue' | 'yellow' | 'pink'>('default');
|
const selectedVariant = ref<'default' | 'blue' | 'yellow' | 'pink'>('default');
|
||||||
const { rerenderKey, forceRerender } = useForceRerender();
|
const { rerenderKey } = useForceRerender();
|
||||||
|
|
||||||
const variantOptions = [
|
const variantOptions = [
|
||||||
{ value: 'default', label: 'Default' },
|
{ value: 'default', label: 'Default' },
|
||||||
|
|||||||
@@ -76,29 +76,9 @@
|
|||||||
@update:model-value="forceRerender"
|
@update:model-value="forceRerender"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<PreviewSelect
|
<PreviewSelect title="Animation Trigger" v-model="animateOn" :options="animateOptions" />
|
||||||
title="Animation Trigger"
|
|
||||||
v-model="animateOn"
|
|
||||||
:options="animateOptions"
|
|
||||||
@update:model-value="
|
|
||||||
val => {
|
|
||||||
animateOn = val as 'view' | 'hover';
|
|
||||||
forceRerender();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<PreviewSelect
|
<PreviewSelect title="Animation Direction" v-model="revealDirection" :options="directionOptions" />
|
||||||
title="Animation Direction"
|
|
||||||
v-model="revealDirection"
|
|
||||||
:options="directionOptions"
|
|
||||||
@update:model-value="
|
|
||||||
val => {
|
|
||||||
revealDirection = val as 'start' | 'end' | 'center';
|
|
||||||
forceRerender();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
/>
|
|
||||||
</Customize>
|
</Customize>
|
||||||
|
|
||||||
<PropTable :data="propData" />
|
<PropTable :data="propData" />
|
||||||
|
|||||||
@@ -18,12 +18,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<Customize>
|
<Customize>
|
||||||
<PreviewSelect
|
<PreviewSelect title="Animation Trigger" v-model="trigger" :options="triggerOptions" />
|
||||||
title="Animation Trigger"
|
|
||||||
v-model="trigger"
|
|
||||||
:options="triggerOptions"
|
|
||||||
@update:model-value="forceRerender"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<PreviewSlider
|
<PreviewSlider
|
||||||
title="Gravity"
|
title="Gravity"
|
||||||
|
|||||||
Reference in New Issue
Block a user