@polymarbot/nuxt-layer-shadcn-ui 0.3.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/app/components/ui/Accordion/index.stories.ts +43 -15
- package/app/components/ui/AdminLayout/index.stories.ts +6 -14
- package/app/components/ui/Alert/index.stories.ts +32 -2
- package/app/components/ui/AlertDialog/index.stories.ts +114 -5
- package/app/components/ui/AsyncDataTable/index.stories.ts +36 -2
- package/app/components/ui/Avatar/index.stories.ts +58 -4
- package/app/components/ui/Badge/index.stories.ts +48 -3
- package/app/components/ui/Breadcrumb/index.stories.ts +8 -19
- package/app/components/ui/Button/index.stories.ts +116 -7
- package/app/components/ui/ButtonGroup/index.stories.ts +63 -4
- package/app/components/ui/Card/index.stories.ts +40 -14
- package/app/components/ui/Checkbox/index.stories.ts +53 -3
- package/app/components/ui/CopyButton/index.stories.ts +77 -5
- package/app/components/ui/DataTable/index.stories.ts +184 -11
- package/app/components/ui/DatePicker/index.stories.ts +56 -7
- package/app/components/ui/DateRangePicker/index.stories.ts +40 -5
- package/app/components/ui/Divider/index.stories.ts +18 -15
- package/app/components/ui/Drawer/index.stories.ts +115 -16
- package/app/components/ui/Drawer/index.vue +27 -12
- package/app/components/ui/Dropdown/index.stories.ts +72 -54
- package/app/components/ui/Dropdown/index.vue +5 -8
- package/app/components/ui/Dropdown/types.ts +3 -8
- package/app/components/ui/FormItem/index.stories.ts +33 -45
- package/app/components/ui/Help/index.stories.ts +34 -2
- package/app/components/ui/Icon/index.stories.ts +41 -2
- package/app/components/ui/Input/index.stories.ts +73 -31
- package/app/components/ui/Input/index.vue +1 -0
- package/app/components/ui/InputCurrency/index.stories.ts +20 -65
- package/app/components/ui/InputNumber/index.stories.ts +31 -58
- package/app/components/ui/InputOtp/index.stories.ts +41 -9
- package/app/components/ui/InputPercent/index.stories.ts +3 -7
- package/app/components/ui/InputRange/index.stories.ts +51 -4
- package/app/components/ui/Loading/index.stories.ts +16 -1
- package/app/components/ui/Markdown/index.stories.ts +9 -0
- package/app/components/ui/Modal/index.stories.ts +133 -16
- package/app/components/ui/Modal/index.vue +27 -12
- package/app/components/ui/ModalContent/index.stories.ts +35 -11
- package/app/components/ui/PageCard/index.stories.ts +154 -56
- package/app/components/ui/Pagination/index.stories.ts +75 -41
- package/app/components/ui/Pagination/index.vue +4 -1
- package/app/components/ui/Popover/index.stories.ts +73 -27
- package/app/components/ui/Popover/index.vue +67 -4
- package/app/components/ui/Popover/types.ts +5 -2
- package/app/components/ui/Qrcode/index.stories.ts +32 -2
- package/app/components/ui/RadioCardGroup/index.stories.ts +45 -6
- package/app/components/ui/RadioGroup/index.stories.ts +64 -52
- package/app/components/ui/ScrollArea/index.stories.ts +21 -23
- package/app/components/ui/SearchSelect/index.stories.ts +73 -24
- package/app/components/ui/Select/index.stories.ts +121 -6
- package/app/components/ui/Select/index.vue +7 -6
- package/app/components/ui/Skeleton/index.stories.ts +34 -2
- package/app/components/ui/Slider/index.stories.ts +67 -4
- package/app/components/ui/Surface/index.stories.ts +86 -5
- package/app/components/ui/Surface/index.vue +115 -2
- package/app/components/ui/Surface/types.ts +2 -0
- package/app/components/ui/Switch/index.stories.ts +46 -0
- package/app/components/ui/Tabs/index.stories.ts +61 -64
- package/app/components/ui/Tag/index.stories.ts +45 -3
- package/app/components/ui/Textarea/index.stories.ts +61 -32
- package/app/components/ui/Toast/index.stories.ts +77 -3
- package/app/components/ui/Tooltip/index.stories.ts +60 -2
- package/app/components/ui/WebLink/index.stories.ts +53 -15
- package/package.json +2 -2
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import EventLog from '#storybook/EventLog.vue'
|
|
2
3
|
import Switch from './index.vue'
|
|
3
4
|
|
|
4
5
|
const meta = {
|
|
@@ -28,4 +29,49 @@ const meta = {
|
|
|
28
29
|
export default meta
|
|
29
30
|
type Story = StoryObj<typeof meta>
|
|
30
31
|
|
|
32
|
+
const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
33
|
+
|
|
31
34
|
export const Default: Story = {}
|
|
35
|
+
|
|
36
|
+
export const Disabled: Story = {
|
|
37
|
+
parameters: {
|
|
38
|
+
...noControls,
|
|
39
|
+
docs: {
|
|
40
|
+
source: {
|
|
41
|
+
code: `
|
|
42
|
+
<template>
|
|
43
|
+
<div class="flex items-center gap-4">
|
|
44
|
+
<Switch :modelValue="false" disabled />
|
|
45
|
+
<Switch :modelValue="true" disabled />
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
`.trim(),
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
render: () => ({
|
|
53
|
+
components: { Switch },
|
|
54
|
+
template: `
|
|
55
|
+
<div class="flex items-center gap-4">
|
|
56
|
+
<Switch :modelValue="false" disabled />
|
|
57
|
+
<Switch :modelValue="true" disabled />
|
|
58
|
+
</div>
|
|
59
|
+
`,
|
|
60
|
+
}),
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const EventHandling: Story = {
|
|
64
|
+
parameters: noControls,
|
|
65
|
+
render: () => ({
|
|
66
|
+
components: { Switch, EventLog },
|
|
67
|
+
setup: () => ({ on: ref(false) }),
|
|
68
|
+
template: `
|
|
69
|
+
<EventLog v-slot="{ record }">
|
|
70
|
+
<Switch
|
|
71
|
+
v-model="on"
|
|
72
|
+
@update:modelValue="(v) => record('update:modelValue', v)"
|
|
73
|
+
/>
|
|
74
|
+
</EventLog>
|
|
75
|
+
`,
|
|
76
|
+
}),
|
|
77
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import EventLog from '#storybook/EventLog.vue'
|
|
2
3
|
import Card from '../Card/index.vue'
|
|
3
4
|
import type { TabsItem } from './types'
|
|
4
5
|
import Tabs from './index.vue'
|
|
@@ -39,6 +40,8 @@ const meta = {
|
|
|
39
40
|
defaultValue: { control: 'text' },
|
|
40
41
|
rounded: { control: 'boolean' },
|
|
41
42
|
iconOnly: { control: 'boolean' },
|
|
43
|
+
listClass: { control: 'text' },
|
|
44
|
+
triggerClass: { control: 'text' },
|
|
42
45
|
},
|
|
43
46
|
args: {
|
|
44
47
|
items,
|
|
@@ -46,6 +49,8 @@ const meta = {
|
|
|
46
49
|
defaultValue: 'account',
|
|
47
50
|
rounded: false,
|
|
48
51
|
iconOnly: false,
|
|
52
|
+
listClass: '',
|
|
53
|
+
triggerClass: '',
|
|
49
54
|
},
|
|
50
55
|
render: args => ({
|
|
51
56
|
components: { Tabs },
|
|
@@ -61,87 +66,61 @@ const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
|
61
66
|
|
|
62
67
|
export const Default: Story = {}
|
|
63
68
|
|
|
64
|
-
export const Controlled: Story = {
|
|
65
|
-
parameters: noControls,
|
|
66
|
-
render: () => ({
|
|
67
|
-
components: { Tabs },
|
|
68
|
-
setup () {
|
|
69
|
-
const value = ref<string>('account')
|
|
70
|
-
return { items, value }
|
|
71
|
-
},
|
|
72
|
-
template: `
|
|
73
|
-
<div class="max-w-md space-y-3">
|
|
74
|
-
<Tabs v-model="value" :items="items" />
|
|
75
|
-
<div class="text-sm text-muted-foreground">Active: {{ value }}</div>
|
|
76
|
-
</div>
|
|
77
|
-
`,
|
|
78
|
-
}),
|
|
79
|
-
}
|
|
80
|
-
|
|
81
69
|
export const IconOnly: Story = {
|
|
82
70
|
parameters: noControls,
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
template: `
|
|
87
|
-
<Tabs
|
|
88
|
-
icon-only
|
|
89
|
-
:items="items"
|
|
90
|
-
default-value="account"
|
|
91
|
-
class="max-w-md"
|
|
92
|
-
/>
|
|
93
|
-
`,
|
|
94
|
-
}),
|
|
71
|
+
args: {
|
|
72
|
+
iconOnly: true,
|
|
73
|
+
},
|
|
95
74
|
}
|
|
96
75
|
|
|
97
76
|
export const Rounded: Story = {
|
|
98
77
|
parameters: noControls,
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
template: `
|
|
103
|
-
<Tabs
|
|
104
|
-
rounded
|
|
105
|
-
:items="items"
|
|
106
|
-
default-value="account"
|
|
107
|
-
class="max-w-md"
|
|
108
|
-
/>
|
|
109
|
-
`,
|
|
110
|
-
}),
|
|
78
|
+
args: {
|
|
79
|
+
rounded: true,
|
|
80
|
+
},
|
|
111
81
|
}
|
|
112
82
|
|
|
113
83
|
export const DisabledItem: Story = {
|
|
114
84
|
parameters: noControls,
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
template: `
|
|
119
|
-
<Tabs
|
|
120
|
-
:items="disabledItems"
|
|
121
|
-
default-value="account"
|
|
122
|
-
class="max-w-md"
|
|
123
|
-
/>
|
|
124
|
-
`,
|
|
125
|
-
}),
|
|
85
|
+
args: {
|
|
86
|
+
items: disabledItems,
|
|
87
|
+
},
|
|
126
88
|
}
|
|
127
89
|
|
|
128
90
|
export const NoContent: Story = {
|
|
129
91
|
parameters: noControls,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
template: `
|
|
134
|
-
<Tabs
|
|
135
|
-
:items="navItems"
|
|
136
|
-
default-value="account"
|
|
137
|
-
class="max-w-md"
|
|
138
|
-
/>
|
|
139
|
-
`,
|
|
140
|
-
}),
|
|
92
|
+
args: {
|
|
93
|
+
items: navItems,
|
|
94
|
+
},
|
|
141
95
|
}
|
|
142
96
|
|
|
143
97
|
export const CustomSlots: Story = {
|
|
144
|
-
parameters:
|
|
98
|
+
parameters: {
|
|
99
|
+
...noControls,
|
|
100
|
+
docs: {
|
|
101
|
+
source: {
|
|
102
|
+
code: `
|
|
103
|
+
<template>
|
|
104
|
+
<Tabs
|
|
105
|
+
:items="items"
|
|
106
|
+
default-value="account"
|
|
107
|
+
list-class="w-full"
|
|
108
|
+
class="max-w-md"
|
|
109
|
+
>
|
|
110
|
+
<template #title="{ item, active }">
|
|
111
|
+
<span :class="active ? 'font-semibold' : ''">{{ item.title }}</span>
|
|
112
|
+
</template>
|
|
113
|
+
<template #content="{ item }">
|
|
114
|
+
<Card>
|
|
115
|
+
<p class="text-sm text-muted-foreground">{{ item.content }}</p>
|
|
116
|
+
</Card>
|
|
117
|
+
</template>
|
|
118
|
+
</Tabs>
|
|
119
|
+
</template>
|
|
120
|
+
`.trim(),
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
145
124
|
render: () => ({
|
|
146
125
|
components: { Tabs, Card },
|
|
147
126
|
setup: () => ({ items }),
|
|
@@ -164,3 +143,21 @@ export const CustomSlots: Story = {
|
|
|
164
143
|
`,
|
|
165
144
|
}),
|
|
166
145
|
}
|
|
146
|
+
|
|
147
|
+
export const EventHandling: Story = {
|
|
148
|
+
parameters: noControls,
|
|
149
|
+
render: () => ({
|
|
150
|
+
components: { Tabs, EventLog },
|
|
151
|
+
setup: () => ({ items, value: ref('account') }),
|
|
152
|
+
template: `
|
|
153
|
+
<EventLog v-slot="{ record }">
|
|
154
|
+
<Tabs
|
|
155
|
+
v-model="value"
|
|
156
|
+
:items="items"
|
|
157
|
+
class="max-w-md"
|
|
158
|
+
@update:modelValue="(v) => record('update:modelValue', v)"
|
|
159
|
+
/>
|
|
160
|
+
</EventLog>
|
|
161
|
+
`,
|
|
162
|
+
}),
|
|
163
|
+
}
|
|
@@ -31,7 +31,20 @@ const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
|
31
31
|
export const Default: Story = {}
|
|
32
32
|
|
|
33
33
|
export const Colors: Story = {
|
|
34
|
-
parameters:
|
|
34
|
+
parameters: {
|
|
35
|
+
...noControls,
|
|
36
|
+
docs: {
|
|
37
|
+
source: {
|
|
38
|
+
code: `
|
|
39
|
+
<template>
|
|
40
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
41
|
+
<Tag v-for="c in colors" :key="c" :color="c">{{ c }}</Tag>
|
|
42
|
+
</div>
|
|
43
|
+
</template>
|
|
44
|
+
`.trim(),
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
},
|
|
35
48
|
render: () => ({
|
|
36
49
|
components: { Tag },
|
|
37
50
|
setup: () => ({ colors }),
|
|
@@ -44,7 +57,20 @@ export const Colors: Story = {
|
|
|
44
57
|
}
|
|
45
58
|
|
|
46
59
|
export const Variants: Story = {
|
|
47
|
-
parameters:
|
|
60
|
+
parameters: {
|
|
61
|
+
...noControls,
|
|
62
|
+
docs: {
|
|
63
|
+
source: {
|
|
64
|
+
code: `
|
|
65
|
+
<template>
|
|
66
|
+
<div class="flex flex-wrap items-center gap-3">
|
|
67
|
+
<Tag v-for="v in variants" :key="v" :variant="v">{{ v }}</Tag>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
`.trim(),
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
},
|
|
48
74
|
render: () => ({
|
|
49
75
|
components: { Tag },
|
|
50
76
|
setup: () => ({ variants }),
|
|
@@ -57,7 +83,23 @@ export const Variants: Story = {
|
|
|
57
83
|
}
|
|
58
84
|
|
|
59
85
|
export const VariantColorMatrix: Story = {
|
|
60
|
-
parameters:
|
|
86
|
+
parameters: {
|
|
87
|
+
...noControls,
|
|
88
|
+
docs: {
|
|
89
|
+
source: {
|
|
90
|
+
code: `
|
|
91
|
+
<template>
|
|
92
|
+
<div class="space-y-3">
|
|
93
|
+
<div v-for="v in variants" :key="v" class="flex flex-wrap items-center gap-3">
|
|
94
|
+
<span class="w-20 text-sm text-muted-foreground">{{ v }}</span>
|
|
95
|
+
<Tag v-for="c in colors" :key="c" :color="c" :variant="v">{{ c }}</Tag>
|
|
96
|
+
</div>
|
|
97
|
+
</div>
|
|
98
|
+
</template>
|
|
99
|
+
`.trim(),
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
61
103
|
render: () => ({
|
|
62
104
|
components: { Tag },
|
|
63
105
|
setup: () => ({ colors, variants }),
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import EventLog from '#storybook/EventLog.vue'
|
|
2
3
|
import Textarea from './index.vue'
|
|
3
4
|
|
|
4
5
|
const meta = {
|
|
@@ -10,8 +11,6 @@ const meta = {
|
|
|
10
11
|
rows: { control: 'number' },
|
|
11
12
|
invalid: { control: 'boolean' },
|
|
12
13
|
class: { control: 'text' },
|
|
13
|
-
disabled: { control: 'boolean' },
|
|
14
|
-
readonly: { control: 'boolean' },
|
|
15
14
|
},
|
|
16
15
|
args: {
|
|
17
16
|
modelValue: '',
|
|
@@ -19,8 +18,6 @@ const meta = {
|
|
|
19
18
|
rows: undefined,
|
|
20
19
|
invalid: false,
|
|
21
20
|
class: '',
|
|
22
|
-
disabled: false,
|
|
23
|
-
readonly: false,
|
|
24
21
|
},
|
|
25
22
|
render: args => ({
|
|
26
23
|
components: { Textarea },
|
|
@@ -31,7 +28,7 @@ const meta = {
|
|
|
31
28
|
</div>
|
|
32
29
|
`,
|
|
33
30
|
}),
|
|
34
|
-
} satisfies Meta
|
|
31
|
+
} satisfies Meta<typeof Textarea>
|
|
35
32
|
|
|
36
33
|
export default meta
|
|
37
34
|
type Story = StoryObj<typeof meta>
|
|
@@ -40,25 +37,19 @@ const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
|
40
37
|
|
|
41
38
|
export const Default: Story = {}
|
|
42
39
|
|
|
43
|
-
export const Controlled: Story = {
|
|
44
|
-
parameters: noControls,
|
|
45
|
-
render: () => ({
|
|
46
|
-
components: { Textarea },
|
|
47
|
-
setup () {
|
|
48
|
-
const value = ref('')
|
|
49
|
-
return { value }
|
|
50
|
-
},
|
|
51
|
-
template: `
|
|
52
|
-
<div class="max-w-sm space-y-2">
|
|
53
|
-
<Textarea v-model="value" placeholder="Type your message here..." />
|
|
54
|
-
<div class="text-sm text-muted-foreground">Value: {{ value }}</div>
|
|
55
|
-
</div>
|
|
56
|
-
`,
|
|
57
|
-
}),
|
|
58
|
-
}
|
|
59
|
-
|
|
60
40
|
export const WithRows: Story = {
|
|
61
|
-
parameters:
|
|
41
|
+
parameters: {
|
|
42
|
+
...noControls,
|
|
43
|
+
docs: {
|
|
44
|
+
source: {
|
|
45
|
+
code: `
|
|
46
|
+
<template>
|
|
47
|
+
<Textarea :rows="6" placeholder="6 rows of height" />
|
|
48
|
+
</template>
|
|
49
|
+
`.trim(),
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
62
53
|
render: () => ({
|
|
63
54
|
components: { Textarea },
|
|
64
55
|
template: `
|
|
@@ -71,36 +62,74 @@ export const WithRows: Story = {
|
|
|
71
62
|
|
|
72
63
|
export const Invalid: Story = {
|
|
73
64
|
parameters: noControls,
|
|
65
|
+
args: {
|
|
66
|
+
invalid: true,
|
|
67
|
+
modelValue: 'Invalid content',
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const Disabled: Story = {
|
|
72
|
+
parameters: {
|
|
73
|
+
...noControls,
|
|
74
|
+
docs: {
|
|
75
|
+
source: {
|
|
76
|
+
code: `
|
|
77
|
+
<template>
|
|
78
|
+
<Textarea disabled model-value="Disabled textarea" />
|
|
79
|
+
</template>
|
|
80
|
+
`.trim(),
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
},
|
|
74
84
|
render: () => ({
|
|
75
85
|
components: { Textarea },
|
|
76
86
|
template: `
|
|
77
87
|
<div class="max-w-sm">
|
|
78
|
-
<Textarea
|
|
88
|
+
<Textarea disabled model-value="Disabled textarea" />
|
|
79
89
|
</div>
|
|
80
90
|
`,
|
|
81
91
|
}),
|
|
82
92
|
}
|
|
83
93
|
|
|
84
|
-
export const
|
|
85
|
-
parameters:
|
|
94
|
+
export const Readonly: Story = {
|
|
95
|
+
parameters: {
|
|
96
|
+
...noControls,
|
|
97
|
+
docs: {
|
|
98
|
+
source: {
|
|
99
|
+
code: `
|
|
100
|
+
<template>
|
|
101
|
+
<Textarea readonly model-value="Readonly content" />
|
|
102
|
+
</template>
|
|
103
|
+
`.trim(),
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
86
107
|
render: () => ({
|
|
87
108
|
components: { Textarea },
|
|
88
109
|
template: `
|
|
89
110
|
<div class="max-w-sm">
|
|
90
|
-
<Textarea
|
|
111
|
+
<Textarea readonly model-value="Readonly content" />
|
|
91
112
|
</div>
|
|
92
113
|
`,
|
|
93
114
|
}),
|
|
94
115
|
}
|
|
95
116
|
|
|
96
|
-
export const
|
|
117
|
+
export const EventHandling: Story = {
|
|
97
118
|
parameters: noControls,
|
|
98
119
|
render: () => ({
|
|
99
|
-
components: { Textarea },
|
|
120
|
+
components: { Textarea, EventLog },
|
|
121
|
+
setup: () => ({ value: ref('') }),
|
|
100
122
|
template: `
|
|
101
|
-
<
|
|
102
|
-
<
|
|
103
|
-
|
|
123
|
+
<EventLog v-slot="{ record }">
|
|
124
|
+
<div class="max-w-sm">
|
|
125
|
+
<Textarea
|
|
126
|
+
v-model="value"
|
|
127
|
+
placeholder="Type to see events"
|
|
128
|
+
@update:modelValue="(v) => record('update:modelValue', v)"
|
|
129
|
+
@change="(v) => record('change', v)"
|
|
130
|
+
/>
|
|
131
|
+
</div>
|
|
132
|
+
</EventLog>
|
|
104
133
|
`,
|
|
105
134
|
}),
|
|
106
135
|
}
|
|
@@ -37,7 +37,35 @@ const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
|
37
37
|
export const Default: Story = {}
|
|
38
38
|
|
|
39
39
|
export const Types: Story = {
|
|
40
|
-
parameters:
|
|
40
|
+
parameters: {
|
|
41
|
+
...noControls,
|
|
42
|
+
docs: {
|
|
43
|
+
source: {
|
|
44
|
+
code: `
|
|
45
|
+
<script setup lang="ts">
|
|
46
|
+
import { toast } from 'vue-sonner'
|
|
47
|
+
|
|
48
|
+
const showDefault = () => toast('This is a default toast')
|
|
49
|
+
const showSuccess = () => toast.success('Operation completed successfully')
|
|
50
|
+
const showError = () => toast.error('Something went wrong')
|
|
51
|
+
const showInfo = () => toast.info('Here is some information')
|
|
52
|
+
const showWarning = () => toast.warning('Please be careful')
|
|
53
|
+
</script>
|
|
54
|
+
|
|
55
|
+
<template>
|
|
56
|
+
<Toast position="bottom-right" />
|
|
57
|
+
<div class="flex flex-wrap gap-3">
|
|
58
|
+
<Button variant="outline" @click="showDefault">Default</Button>
|
|
59
|
+
<Button variant="outline" @click="showSuccess">Success</Button>
|
|
60
|
+
<Button variant="outline" @click="showError">Error</Button>
|
|
61
|
+
<Button variant="outline" @click="showInfo">Info</Button>
|
|
62
|
+
<Button variant="outline" @click="showWarning">Warning</Button>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
`.trim(),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
41
69
|
render: () => ({
|
|
42
70
|
components: { Toast, Button },
|
|
43
71
|
setup () {
|
|
@@ -64,7 +92,27 @@ export const Types: Story = {
|
|
|
64
92
|
}
|
|
65
93
|
|
|
66
94
|
export const WithDescription: Story = {
|
|
67
|
-
parameters:
|
|
95
|
+
parameters: {
|
|
96
|
+
...noControls,
|
|
97
|
+
docs: {
|
|
98
|
+
source: {
|
|
99
|
+
code: `
|
|
100
|
+
<script setup lang="ts">
|
|
101
|
+
import { toast } from 'vue-sonner'
|
|
102
|
+
|
|
103
|
+
const show = () => toast('Event created', {
|
|
104
|
+
description: 'Your event has been scheduled for tomorrow at 3:00 PM.',
|
|
105
|
+
})
|
|
106
|
+
</script>
|
|
107
|
+
|
|
108
|
+
<template>
|
|
109
|
+
<Toast position="bottom-right" />
|
|
110
|
+
<Button variant="outline" @click="show">Show Toast with Description</Button>
|
|
111
|
+
</template>
|
|
112
|
+
`.trim(),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
},
|
|
68
116
|
render: () => ({
|
|
69
117
|
components: { Toast, Button },
|
|
70
118
|
setup () {
|
|
@@ -83,7 +131,33 @@ export const WithDescription: Story = {
|
|
|
83
131
|
}
|
|
84
132
|
|
|
85
133
|
export const Positions: Story = {
|
|
86
|
-
parameters:
|
|
134
|
+
parameters: {
|
|
135
|
+
...noControls,
|
|
136
|
+
docs: {
|
|
137
|
+
source: {
|
|
138
|
+
code: `
|
|
139
|
+
<script setup lang="ts">
|
|
140
|
+
import { toast } from 'vue-sonner'
|
|
141
|
+
|
|
142
|
+
const positions = [ 'top-left', 'top-right', 'bottom-left', 'bottom-right', 'top-center', 'bottom-center' ] as const
|
|
143
|
+
const current = ref<typeof positions[number]>('bottom-right')
|
|
144
|
+
|
|
145
|
+
const show = (pos: typeof positions[number]) => {
|
|
146
|
+
current.value = pos
|
|
147
|
+
nextTick(() => toast(\`Toast at \${pos}\`))
|
|
148
|
+
}
|
|
149
|
+
</script>
|
|
150
|
+
|
|
151
|
+
<template>
|
|
152
|
+
<Toast :position="current" />
|
|
153
|
+
<div class="flex flex-wrap gap-3">
|
|
154
|
+
<Button v-for="p in positions" :key="p" variant="outline" @click="show(p)">{{ p }}</Button>
|
|
155
|
+
</div>
|
|
156
|
+
</template>
|
|
157
|
+
`.trim(),
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
},
|
|
87
161
|
render: () => ({
|
|
88
162
|
components: { Toast, Button },
|
|
89
163
|
setup () {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import EventLog from '#storybook/EventLog.vue'
|
|
2
3
|
import Button from '../Button/index.vue'
|
|
3
4
|
import Tooltip from './index.vue'
|
|
4
5
|
|
|
@@ -12,12 +13,14 @@ const meta = {
|
|
|
12
13
|
position: { control: 'select', options: positions },
|
|
13
14
|
disabled: { control: 'boolean' },
|
|
14
15
|
disableClosingTrigger: { control: 'boolean' },
|
|
16
|
+
class: { control: 'text' },
|
|
15
17
|
},
|
|
16
18
|
args: {
|
|
17
19
|
text: 'This is a tooltip',
|
|
18
20
|
position: 'top',
|
|
19
21
|
disabled: false,
|
|
20
22
|
disableClosingTrigger: false,
|
|
23
|
+
class: '',
|
|
21
24
|
},
|
|
22
25
|
render: args => ({
|
|
23
26
|
components: { Tooltip, Button },
|
|
@@ -38,7 +41,31 @@ const noControls = { controls: { disable: true }} satisfies Story['parameters']
|
|
|
38
41
|
export const Default: Story = {}
|
|
39
42
|
|
|
40
43
|
export const Positions: Story = {
|
|
41
|
-
parameters:
|
|
44
|
+
parameters: {
|
|
45
|
+
...noControls,
|
|
46
|
+
docs: {
|
|
47
|
+
source: {
|
|
48
|
+
code: `
|
|
49
|
+
<template>
|
|
50
|
+
<div class="flex flex-wrap items-center gap-4 py-10 justify-center">
|
|
51
|
+
<Tooltip text="Top tooltip" position="top">
|
|
52
|
+
<Button variant="outline">Top</Button>
|
|
53
|
+
</Tooltip>
|
|
54
|
+
<Tooltip text="Bottom tooltip" position="bottom">
|
|
55
|
+
<Button variant="outline">Bottom</Button>
|
|
56
|
+
</Tooltip>
|
|
57
|
+
<Tooltip text="Left tooltip" position="left">
|
|
58
|
+
<Button variant="outline">Left</Button>
|
|
59
|
+
</Tooltip>
|
|
60
|
+
<Tooltip text="Right tooltip" position="right">
|
|
61
|
+
<Button variant="outline">Right</Button>
|
|
62
|
+
</Tooltip>
|
|
63
|
+
</div>
|
|
64
|
+
</template>
|
|
65
|
+
`.trim(),
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
},
|
|
42
69
|
render: () => ({
|
|
43
70
|
components: { Tooltip, Button },
|
|
44
71
|
template: `
|
|
@@ -61,7 +88,20 @@ export const Positions: Story = {
|
|
|
61
88
|
}
|
|
62
89
|
|
|
63
90
|
export const LongText: Story = {
|
|
64
|
-
parameters:
|
|
91
|
+
parameters: {
|
|
92
|
+
...noControls,
|
|
93
|
+
docs: {
|
|
94
|
+
source: {
|
|
95
|
+
code: `
|
|
96
|
+
<template>
|
|
97
|
+
<Tooltip text="This is a longer tooltip message that demonstrates how the tooltip handles multi-line content and wraps properly within its container.">
|
|
98
|
+
<Button variant="outline">Long Tooltip</Button>
|
|
99
|
+
</Tooltip>
|
|
100
|
+
</template>
|
|
101
|
+
`.trim(),
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
},
|
|
65
105
|
render: () => ({
|
|
66
106
|
components: { Tooltip, Button },
|
|
67
107
|
template: `
|
|
@@ -71,3 +111,21 @@ export const LongText: Story = {
|
|
|
71
111
|
`,
|
|
72
112
|
}),
|
|
73
113
|
}
|
|
114
|
+
|
|
115
|
+
export const EventHandling: Story = {
|
|
116
|
+
parameters: noControls,
|
|
117
|
+
render: () => ({
|
|
118
|
+
components: { Tooltip, Button, EventLog },
|
|
119
|
+
template: `
|
|
120
|
+
<EventLog v-slot="{ record }">
|
|
121
|
+
<Tooltip
|
|
122
|
+
text="Hover or focus to fire events"
|
|
123
|
+
@open="record('open')"
|
|
124
|
+
@close="record('close')"
|
|
125
|
+
>
|
|
126
|
+
<Button variant="outline">Hover me</Button>
|
|
127
|
+
</Tooltip>
|
|
128
|
+
</EventLog>
|
|
129
|
+
`,
|
|
130
|
+
}),
|
|
131
|
+
}
|