-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathShowSelect.vue
More file actions
102 lines (94 loc) · 2.5 KB
/
ShowSelect.vue
File metadata and controls
102 lines (94 loc) · 2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<template>
<div class="select-demo-container">
<CodeBlock v-if="type === 'default'">
<template #preview>
<PUSelect
v-model="demoValue"
:options="[{ value: 1, label: 'Option 1' }, { value: 2, label: 'Option 2' }]"
/>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
<CodeBlock v-if="type === 'placeholder'">
<template #preview>
<PUSelect
v-model="placeholderValue"
placeholder="Select something"
:options="[{ value: 'a', label: 'Item A' }, { value: 'b', label: 'Item B' }]"
/>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
<CodeBlock v-if="type === 'sizes'">
<template #preview>
<div class="flex gap-2 w-1/2">
<PUSelect
v-model="smallValue"
size="small"
:options="sizeOptions"
/>
<PUSelect
v-model="largeValue"
size="large"
:options="sizeOptions"
/>
</div>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
<CodeBlock v-if="type === 'example-option'">
<template #preview>
<PUSelect
v-model="presetValue"
:example-option="{ value: 'preset', label: 'Preselected Option' }"
:options="presetOptions"
/>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
<CodeBlock v-if="type === 'with-label'">
<template #preview>
<div class="flex flex-col w-1/3">
<PULabel id="label">
with label
</PULabel>
<PUSelect
v-model="presetValue"
placeholder="Choose an option"
:options="presetOptions"
/>
</div>
</template>
<template #code>
<slot name="code" />
</template>
</CodeBlock>
</div>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
defineProps<{
type: 'default' | 'placeholder' | 'sizes' | 'example-option' | 'with-label'
}>()
const demoValue = ref()
const placeholderValue = ref()
const smallValue = ref()
const largeValue = ref()
const presetValue = ref()
const sizeOptions = [
{ value: 'sm', label: 'Small' },
{ value: 'lg', label: 'Large' },
]
const presetOptions = [
{ value: 'preset', label: 'Preselected Option' },
{ value: 'opt2', label: 'Regular Option' },
]
</script>