@citizenplane/pimp 16.0.3 → 16.2.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/dist/pimp.es.js +781 -757
- package/dist/pimp.umd.js +21 -21
- package/dist/style.css +1 -1
- package/package.json +10 -8
- package/src/components/CpDate.vue +3 -1
- package/src/components/CpHeading.vue +4 -5
- package/src/components/CpMultiselect.vue +2 -5
- package/src/components/CpTable.vue +4 -2
- package/src/components/CpTelInput.vue +18 -12
- package/src/components/CpText.vue +141 -0
- package/src/components/CpToast.vue +1 -1
- package/src/components/CpTransitionExpand.vue +23 -20
- package/src/components/index.ts +2 -0
- package/src/libs/CoreDatepicker.vue +1 -0
- package/src/stories/BaseInputLabel.stories.ts +36 -9
- package/src/stories/Colors.mdx +9 -0
- package/src/stories/Colors.stories.ts +177 -0
- package/src/stories/CpAccordion.stories.ts +188 -159
- package/src/stories/CpAccordionGroup.stories.ts +51 -95
- package/src/stories/CpAirlineLogo.stories.ts +52 -28
- package/src/stories/CpAlert.stories.ts +196 -159
- package/src/stories/CpBadge.stories.ts +260 -194
- package/src/stories/CpButton.stories.ts +257 -426
- package/src/stories/CpCheckbox.stories.ts +102 -30
- package/src/stories/CpContextualMenu.stories.ts +14 -9
- package/src/stories/CpDate.stories.ts +53 -26
- package/src/stories/CpDatepicker.stories.ts +53 -80
- package/src/stories/CpDialog.stories.ts +23 -2
- package/src/stories/CpHeading.stories.ts +60 -20
- package/src/stories/CpIcon.stories.ts +98 -31
- package/src/stories/CpInput.stories.ts +164 -73
- package/src/stories/CpItemActions.stories.ts +23 -12
- package/src/stories/CpLoader.stories.ts +55 -7
- package/src/stories/CpMenuItem.stories.ts +53 -27
- package/src/stories/CpMultiselect.stories.ts +53 -72
- package/src/stories/CpPartnerBadge.stories.ts +58 -76
- package/src/stories/CpRadio.stories.ts +45 -49
- package/src/stories/CpRadioGroup.stories.ts +47 -40
- package/src/stories/CpSelect.stories.ts +108 -34
- package/src/stories/CpSelectMenu.stories.ts +66 -55
- package/src/stories/CpSelectableButton.stories.ts +170 -81
- package/src/stories/CpSwitch.stories.ts +136 -134
- package/src/stories/CpTable.stories.ts +69 -13
- package/src/stories/CpTableEmptyState.stories.ts +11 -7
- package/src/stories/CpTabs.stories.ts +23 -5
- package/src/stories/CpTelInput.stories.ts +28 -19
- package/src/stories/CpText.stories.ts +131 -0
- package/src/stories/CpTextarea.stories.ts +74 -27
- package/src/stories/CpToast.stories.ts +75 -109
- package/src/stories/CpTooltip.stories.ts +82 -77
- package/src/stories/CpTransitionCounter.stories.ts +5 -1
- package/src/stories/CpTransitionExpand.stories.ts +12 -7
- package/src/stories/CpTransitionListItems.stories.ts +6 -1
- package/src/stories/CpTransitionSize.stories.ts +9 -1
- package/src/stories/CpTransitionSlide.stories.ts +5 -1
- package/src/stories/CpTransitionTabContent.stories.ts +5 -1
- package/src/stories/Dimensions.mdx +9 -0
- package/src/stories/Dimensions.stories.ts +119 -0
- package/src/stories/Easings.mdx +9 -0
- package/src/stories/Easings.stories.ts +101 -0
- package/src/stories/FocusRings.mdx +9 -0
- package/src/stories/FocusRings.stories.ts +74 -0
- package/src/stories/Shadows.mdx +9 -0
- package/src/stories/Shadows.stories.ts +100 -0
- package/src/stories/Typography.mdx +9 -0
- package/src/stories/Typography.stories.ts +181 -0
- package/src/stories/documentationStyles.ts +2 -10
- package/src/stories/tokenUtils.ts +259 -0
- package/src/types/primevue-toasteventbus.d.ts +14 -0
- package/tsconfig.json +1 -0
- package/.lintstagedrc.json +0 -4
|
@@ -1,19 +1,46 @@
|
|
|
1
1
|
import { useToast } from 'primevue/usetoast'
|
|
2
2
|
import { ref } from 'vue'
|
|
3
3
|
|
|
4
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
4
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
5
5
|
|
|
6
6
|
import { CpToastTypes } from '@/constants/CpToastTypes'
|
|
7
7
|
|
|
8
8
|
import CpToast from '@/components/CpToast.vue'
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
type CpToastPosition =
|
|
11
|
+
| 'bottom-center'
|
|
12
|
+
| 'bottom-left'
|
|
13
|
+
| 'bottom-right'
|
|
14
|
+
| 'center'
|
|
15
|
+
| 'top-center'
|
|
16
|
+
| 'top-left'
|
|
17
|
+
| 'top-right'
|
|
18
|
+
|
|
19
|
+
/** `CpToast` has no `defineProps`; layout props are passed through to PrimeVue `Toast`. */
|
|
20
|
+
type CpToastStoryArgs = {
|
|
21
|
+
enableHaptics?: boolean
|
|
22
|
+
group?: string
|
|
23
|
+
position?: CpToastPosition
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const toastPositions = [
|
|
27
|
+
'center',
|
|
28
|
+
'top-left',
|
|
29
|
+
'top-center',
|
|
30
|
+
'top-right',
|
|
31
|
+
'bottom-left',
|
|
32
|
+
'bottom-center',
|
|
33
|
+
'bottom-right',
|
|
34
|
+
] as const
|
|
35
|
+
|
|
36
|
+
const meta = {
|
|
37
|
+
title: 'Molecules/CpToast',
|
|
12
38
|
component: CpToast,
|
|
13
39
|
argTypes: {
|
|
14
40
|
position: {
|
|
15
41
|
control: { type: 'select' },
|
|
16
|
-
options:
|
|
42
|
+
options: toastPositions,
|
|
43
|
+
description: 'Where to anchor the toast stack on the screen',
|
|
17
44
|
},
|
|
18
45
|
},
|
|
19
46
|
args: {
|
|
@@ -21,13 +48,17 @@ const meta: Meta<typeof CpToast> = {
|
|
|
21
48
|
group: undefined,
|
|
22
49
|
enableHaptics: false,
|
|
23
50
|
},
|
|
24
|
-
}
|
|
51
|
+
} satisfies Meta<CpToastStoryArgs>
|
|
25
52
|
|
|
26
53
|
export default meta
|
|
27
54
|
|
|
28
|
-
type Story = StoryObj<
|
|
55
|
+
type Story = StoryObj<CpToastStoryArgs>
|
|
29
56
|
|
|
30
|
-
|
|
57
|
+
/**
|
|
58
|
+
* Trigger toasts of every severity using the `useToast()` composable.
|
|
59
|
+
* Buttons in the canvas call `toast.add()` with a different `severity`.
|
|
60
|
+
*/
|
|
61
|
+
export const Severities: Story = {
|
|
31
62
|
render: (args) => ({
|
|
32
63
|
components: { CpToast },
|
|
33
64
|
setup() {
|
|
@@ -35,115 +66,54 @@ export const Default: Story = {
|
|
|
35
66
|
|
|
36
67
|
const baseOptions = {
|
|
37
68
|
severity: CpToastTypes.SECONDARY,
|
|
38
|
-
summary:
|
|
69
|
+
summary: "Hello i'm a cpToast!",
|
|
39
70
|
detail: 'This is a cpToast description.',
|
|
40
71
|
enableHaptics: true,
|
|
41
72
|
}
|
|
42
73
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const notifyInfo = () => {
|
|
46
|
-
toast.add({
|
|
47
|
-
...baseOptions,
|
|
48
|
-
severity: CpToastTypes.INFO,
|
|
49
|
-
})
|
|
50
|
-
}
|
|
74
|
+
const notify = (severity: string) => toast.add({ ...baseOptions, severity })
|
|
51
75
|
|
|
52
|
-
|
|
53
|
-
toast.add({
|
|
54
|
-
...baseOptions,
|
|
55
|
-
severity: CpToastTypes.ERROR,
|
|
56
|
-
})
|
|
57
|
-
}
|
|
58
|
-
const notifySuccess = () => {
|
|
59
|
-
toast.add({
|
|
60
|
-
...baseOptions,
|
|
61
|
-
severity: CpToastTypes.SUCCESS,
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
const notifyWarning = () => {
|
|
65
|
-
toast.add({
|
|
66
|
-
...baseOptions,
|
|
67
|
-
severity: CpToastTypes.WARNING,
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return { args, notifySecondary, notifyInfo, notifyError, notifySuccess, notifyWarning }
|
|
76
|
+
return { args, notify }
|
|
72
77
|
},
|
|
73
78
|
template: `
|
|
74
79
|
<div style="padding: 16px;">
|
|
75
|
-
|
|
76
80
|
<CpToast v-bind="args" />
|
|
77
81
|
|
|
78
|
-
<div style="display:flex; gap: 12px; align-items:center;">
|
|
79
|
-
<button
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
>
|
|
84
|
-
Show secondary toast
|
|
85
|
-
</button>
|
|
86
|
-
|
|
87
|
-
<button
|
|
88
|
-
type="button"
|
|
89
|
-
@click="notifyInfo"
|
|
90
|
-
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
91
|
-
>
|
|
92
|
-
Show info toast
|
|
93
|
-
</button>
|
|
94
|
-
|
|
95
|
-
<button
|
|
96
|
-
type="button"
|
|
97
|
-
@click="notifyError"
|
|
98
|
-
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
99
|
-
>
|
|
100
|
-
Show error toast
|
|
101
|
-
</button>
|
|
102
|
-
|
|
103
|
-
<button
|
|
104
|
-
type="button"
|
|
105
|
-
@click="notifySuccess"
|
|
106
|
-
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
107
|
-
>
|
|
108
|
-
Show success toast
|
|
109
|
-
</button>
|
|
110
|
-
|
|
111
|
-
<button
|
|
112
|
-
type="button"
|
|
113
|
-
@click="notifyWarning"
|
|
114
|
-
style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor:pointer;"
|
|
115
|
-
>
|
|
116
|
-
Show warning toast
|
|
117
|
-
</button>
|
|
82
|
+
<div style="display: flex; gap: 12px; align-items: center; flex-wrap: wrap;">
|
|
83
|
+
<button type="button" @click="notify('secondary')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Secondary</button>
|
|
84
|
+
<button type="button" @click="notify('info')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Info</button>
|
|
85
|
+
<button type="button" @click="notify('success')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Success</button>
|
|
86
|
+
<button type="button" @click="notify('warning')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Warning</button>
|
|
87
|
+
<button type="button" @click="notify('error')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Error</button>
|
|
118
88
|
</div>
|
|
119
89
|
|
|
120
|
-
<p style="margin-top:12px; color
|
|
121
|
-
|
|
90
|
+
<p style="margin-top: 12px; color: #666;">
|
|
91
|
+
Toasts are triggered via <code>useToast()</code>.
|
|
122
92
|
</p>
|
|
123
93
|
</div>
|
|
124
94
|
`,
|
|
125
95
|
}),
|
|
126
96
|
}
|
|
127
97
|
|
|
98
|
+
/**
|
|
99
|
+
* Toasts with a `life` (auto-close) duration can optionally render a
|
|
100
|
+
* countdown bar via the `showTimer` option.
|
|
101
|
+
*/
|
|
128
102
|
export const WithTimer: Story = {
|
|
129
|
-
args: {
|
|
130
|
-
...Default.args,
|
|
131
|
-
},
|
|
132
103
|
render: (args) => ({
|
|
133
104
|
components: { CpToast },
|
|
134
105
|
setup() {
|
|
135
106
|
const toast = useToast()
|
|
136
|
-
|
|
137
107
|
const showTimer = ref(false)
|
|
138
108
|
|
|
139
109
|
const notifyWithTimer = () => {
|
|
140
110
|
toast.add({
|
|
141
111
|
severity: CpToastTypes.INFO,
|
|
142
|
-
summary: "Hello i'm a cpToast with a timer
|
|
112
|
+
summary: "Hello i'm a cpToast with a timer!",
|
|
143
113
|
detail: 'This is a cpToast description.',
|
|
144
114
|
life: 2500,
|
|
145
115
|
showTimer: showTimer.value,
|
|
146
|
-
})
|
|
116
|
+
} as never)
|
|
147
117
|
}
|
|
148
118
|
|
|
149
119
|
return { args, notifyWithTimer, showTimer }
|
|
@@ -151,20 +121,21 @@ export const WithTimer: Story = {
|
|
|
151
121
|
template: `
|
|
152
122
|
<div style="padding: 16px;">
|
|
153
123
|
<CpToast v-bind="args" />
|
|
154
|
-
|
|
155
124
|
<cp-button @click="notifyWithTimer">Show toast with timer</cp-button>
|
|
156
|
-
<div style="margin-top: 24px">
|
|
157
|
-
<cp-switch v-model="showTimer" label="Show timer bar
|
|
125
|
+
<div style="margin-top: 24px;">
|
|
126
|
+
<cp-switch v-model="showTimer" label="Show timer bar?" />
|
|
158
127
|
</div>
|
|
159
128
|
</div>
|
|
160
129
|
`,
|
|
161
130
|
}),
|
|
162
131
|
}
|
|
163
132
|
|
|
133
|
+
/**
|
|
134
|
+
* Pass `primaryAction` / `secondaryAction` to render buttons inside the
|
|
135
|
+
* toast. Each action exposes a label, optional icons and an `onClick`
|
|
136
|
+
* callback.
|
|
137
|
+
*/
|
|
164
138
|
export const WithActions: Story = {
|
|
165
|
-
args: {
|
|
166
|
-
...Default.args,
|
|
167
|
-
},
|
|
168
139
|
render: (args) => ({
|
|
169
140
|
components: { CpToast },
|
|
170
141
|
setup() {
|
|
@@ -173,23 +144,19 @@ export const WithActions: Story = {
|
|
|
173
144
|
const notifyWithActions = () => {
|
|
174
145
|
toast.add({
|
|
175
146
|
severity: CpToastTypes.INFO,
|
|
176
|
-
summary: "Hello i'm a cpToast with actions
|
|
147
|
+
summary: "Hello i'm a cpToast with actions!",
|
|
177
148
|
detail: 'This is a cpToast description.',
|
|
178
149
|
primaryAction: {
|
|
179
150
|
label: 'Primary action',
|
|
180
151
|
leadingIcon: 'user',
|
|
181
|
-
onClick: () =>
|
|
182
|
-
console.log('Primary action clicked')
|
|
183
|
-
},
|
|
152
|
+
onClick: () => console.log('Primary action clicked'),
|
|
184
153
|
},
|
|
185
154
|
secondaryAction: {
|
|
186
155
|
label: 'Secondary action',
|
|
187
156
|
trailingIcon: 'arrow-right',
|
|
188
|
-
onClick: () =>
|
|
189
|
-
console.log('Secondary action clicked')
|
|
190
|
-
},
|
|
157
|
+
onClick: () => console.log('Secondary action clicked'),
|
|
191
158
|
},
|
|
192
|
-
})
|
|
159
|
+
} as never)
|
|
193
160
|
}
|
|
194
161
|
|
|
195
162
|
return { args, notifyWithActions }
|
|
@@ -197,37 +164,36 @@ export const WithActions: Story = {
|
|
|
197
164
|
template: `
|
|
198
165
|
<div style="padding: 16px;">
|
|
199
166
|
<CpToast v-bind="args" />
|
|
200
|
-
|
|
201
167
|
<cp-button @click="notifyWithActions">Show toast with actions</cp-button>
|
|
202
168
|
</div>
|
|
203
169
|
`,
|
|
204
170
|
}),
|
|
205
171
|
}
|
|
206
172
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
173
|
+
/**
|
|
174
|
+
* The toast stack is positioned via the `position` prop on the
|
|
175
|
+
* `<CpToast>` mount point. Update the control to try every anchor.
|
|
176
|
+
*/
|
|
177
|
+
export const Positions: Story = {
|
|
211
178
|
render: (args) => ({
|
|
212
179
|
components: { CpToast },
|
|
213
180
|
setup() {
|
|
214
181
|
const toast = useToast()
|
|
215
182
|
|
|
216
|
-
const
|
|
183
|
+
const notify = () => {
|
|
217
184
|
toast.add({
|
|
218
185
|
severity: CpToastTypes.INFO,
|
|
219
|
-
summary: "Hello i'm a cpToast
|
|
186
|
+
summary: "Hello i'm a cpToast!",
|
|
220
187
|
detail: 'This is a cpToast description.',
|
|
221
188
|
})
|
|
222
189
|
}
|
|
223
190
|
|
|
224
|
-
return { args,
|
|
191
|
+
return { args, notify }
|
|
225
192
|
},
|
|
226
193
|
template: `
|
|
227
194
|
<div style="padding: 16px;">
|
|
228
195
|
<CpToast v-bind="args" />
|
|
229
|
-
|
|
230
|
-
<cp-button @click="notifyWithPositions">Show toast with positions</cp-button>
|
|
196
|
+
<cp-button @click="notify">Show toast</cp-button>
|
|
231
197
|
</div>
|
|
232
198
|
`,
|
|
233
199
|
}),
|
|
@@ -1,9 +1,12 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
1
|
+
import type { Args, Meta, StoryObj } from '@storybook/vue3-vite'
|
|
2
2
|
|
|
3
3
|
import CpTooltip from '@/components/CpTooltip.vue'
|
|
4
4
|
|
|
5
|
+
const tooltipColors = ['accent', 'neutral'] as const
|
|
6
|
+
const tooltipPlacements = ['top', 'right', 'bottom', 'left'] as const
|
|
7
|
+
|
|
5
8
|
const meta = {
|
|
6
|
-
title: '
|
|
9
|
+
title: 'Atoms/CpTooltip',
|
|
7
10
|
component: CpTooltip,
|
|
8
11
|
argTypes: {
|
|
9
12
|
content: {
|
|
@@ -16,12 +19,12 @@ const meta = {
|
|
|
16
19
|
},
|
|
17
20
|
color: {
|
|
18
21
|
control: 'select',
|
|
19
|
-
options:
|
|
22
|
+
options: tooltipColors,
|
|
20
23
|
description: 'The color variant',
|
|
21
24
|
},
|
|
22
25
|
placement: {
|
|
23
26
|
control: 'select',
|
|
24
|
-
options:
|
|
27
|
+
options: tooltipPlacements,
|
|
25
28
|
description: 'The placement of the tooltip',
|
|
26
29
|
},
|
|
27
30
|
distance: {
|
|
@@ -34,53 +37,53 @@ const meta = {
|
|
|
34
37
|
export default meta
|
|
35
38
|
type Story = StoryObj<typeof meta>
|
|
36
39
|
|
|
40
|
+
const paddedRender = (args: Args) => ({
|
|
41
|
+
components: { CpTooltip },
|
|
42
|
+
setup() {
|
|
43
|
+
return { args }
|
|
44
|
+
},
|
|
45
|
+
template: `
|
|
46
|
+
<div style="padding: 100px; text-align: center;">
|
|
47
|
+
<CpTooltip v-bind="args">
|
|
48
|
+
<button>Hover me</button>
|
|
49
|
+
</CpTooltip>
|
|
50
|
+
</div>
|
|
51
|
+
`,
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Default tooltip. Hover the trigger to reveal it. Use the controls to
|
|
56
|
+
* experiment with each prop in isolation.
|
|
57
|
+
*/
|
|
37
58
|
export const Default: Story = {
|
|
38
59
|
args: {
|
|
39
60
|
content: 'Tooltip content',
|
|
40
61
|
placement: 'top',
|
|
41
62
|
distance: 8,
|
|
42
63
|
},
|
|
43
|
-
render:
|
|
44
|
-
components: { CpTooltip },
|
|
45
|
-
setup() {
|
|
46
|
-
return { args }
|
|
47
|
-
},
|
|
48
|
-
template: `
|
|
49
|
-
<div style="padding: 100px; text-align: center;">
|
|
50
|
-
<CpTooltip v-bind="args">
|
|
51
|
-
<button>Hover me</button>
|
|
52
|
-
</CpTooltip>
|
|
53
|
-
</div>
|
|
54
|
-
`,
|
|
55
|
-
}),
|
|
64
|
+
render: paddedRender,
|
|
56
65
|
}
|
|
57
66
|
|
|
58
|
-
|
|
59
|
-
|
|
67
|
+
/* -------------------------------------------------------------------------- */
|
|
68
|
+
/* Placements */
|
|
69
|
+
/* -------------------------------------------------------------------------- */
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* All four placements rendered on one page. Tooltips flip automatically if
|
|
73
|
+
* they don't fit on the chosen side.
|
|
74
|
+
*/
|
|
75
|
+
export const Placements: Story = {
|
|
76
|
+
parameters: { controls: { disable: true } },
|
|
77
|
+
render: () => ({
|
|
60
78
|
components: { CpTooltip },
|
|
61
79
|
setup() {
|
|
62
|
-
return {
|
|
80
|
+
return { tooltipPlacements }
|
|
63
81
|
},
|
|
64
82
|
template: `
|
|
65
|
-
<div style="display: flex;
|
|
66
|
-
<div>
|
|
67
|
-
<CpTooltip content="
|
|
68
|
-
<button>
|
|
69
|
-
</CpTooltip>
|
|
70
|
-
</div>
|
|
71
|
-
<div>
|
|
72
|
-
<CpTooltip content="Right tooltip" placement="right">
|
|
73
|
-
<button>Right</button>
|
|
74
|
-
</CpTooltip>
|
|
75
|
-
</div>
|
|
76
|
-
<div>
|
|
77
|
-
<CpTooltip content="Bottom tooltip" placement="bottom">
|
|
78
|
-
<button>Bottom</button>
|
|
79
|
-
</CpTooltip>
|
|
80
|
-
</div>
|
|
81
|
-
<div>
|
|
82
|
-
<CpTooltip content="Left tooltip" placement="left">
|
|
83
|
-
<button>Left</button>
|
|
83
|
+
<div style="display: flex; gap: 32px; padding: 100px; justify-content: center; flex-wrap: wrap;">
|
|
84
|
+
<div v-for="placement in tooltipPlacements" :key="placement">
|
|
85
|
+
<CpTooltip :content="placement + ' tooltip'" :placement="placement">
|
|
86
|
+
<button>{{ placement }}</button>
|
|
84
87
|
</CpTooltip>
|
|
85
88
|
</div>
|
|
86
89
|
</div>
|
|
@@ -88,11 +91,17 @@ export const AllPlacements: Story = {
|
|
|
88
91
|
}),
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
/* -------------------------------------------------------------------------- */
|
|
95
|
+
/* Content */
|
|
96
|
+
/* -------------------------------------------------------------------------- */
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Pass rich HTML content via the `#content` slot — perfect for links,
|
|
100
|
+
* formatting or small compositions.
|
|
101
|
+
*/
|
|
91
102
|
export const WithHTMLContent: Story = {
|
|
92
|
-
args: {
|
|
93
|
-
|
|
94
|
-
},
|
|
95
|
-
render: (args) => ({
|
|
103
|
+
args: { placement: 'top' },
|
|
104
|
+
render: (args: Args) => ({
|
|
96
105
|
components: { CpTooltip },
|
|
97
106
|
setup() {
|
|
98
107
|
return { args }
|
|
@@ -110,55 +119,51 @@ export const WithHTMLContent: Story = {
|
|
|
110
119
|
}),
|
|
111
120
|
}
|
|
112
121
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
render: (args) => ({
|
|
119
|
-
components: { CpTooltip },
|
|
120
|
-
setup() {
|
|
121
|
-
return { args }
|
|
122
|
-
},
|
|
123
|
-
template: `
|
|
124
|
-
<div style="padding: 100px; text-align: center;">
|
|
125
|
-
<CpTooltip v-bind="args">
|
|
126
|
-
<button type="button">Hover me</button>
|
|
127
|
-
<template #subcontent>
|
|
128
|
-
<p>Optional subcontent via slot, it can be a long text to see how it works and includes <b>HTML</b> <u>tags</u></p>
|
|
129
|
-
</template>
|
|
130
|
-
</CpTooltip>
|
|
131
|
-
</div>
|
|
132
|
-
`,
|
|
133
|
-
}),
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
export const WithSubcontentProp: Story = {
|
|
122
|
+
/**
|
|
123
|
+
* A secondary line of content displayed below the main content. Can be
|
|
124
|
+
* provided as a `subcontent` prop or through the `#subcontent` slot.
|
|
125
|
+
*/
|
|
126
|
+
export const WithSubcontent: Story = {
|
|
137
127
|
args: {
|
|
138
128
|
content: 'Main content',
|
|
139
129
|
subcontent: 'Optional subcontent via prop',
|
|
140
130
|
placement: 'top',
|
|
141
131
|
},
|
|
142
|
-
render: (args) => ({
|
|
132
|
+
render: (args: Args) => ({
|
|
143
133
|
components: { CpTooltip },
|
|
144
134
|
setup() {
|
|
145
135
|
return { args }
|
|
146
136
|
},
|
|
147
137
|
template: `
|
|
148
|
-
<div style="padding: 100px;
|
|
149
|
-
<
|
|
150
|
-
<
|
|
151
|
-
|
|
138
|
+
<div style="display: flex; gap: 48px; padding: 100px; justify-content: center; flex-wrap: wrap;">
|
|
139
|
+
<div>
|
|
140
|
+
<CpTooltip v-bind="args">
|
|
141
|
+
<button type="button">Subcontent via prop</button>
|
|
142
|
+
</CpTooltip>
|
|
143
|
+
</div>
|
|
144
|
+
<div>
|
|
145
|
+
<CpTooltip :content="args.content" :placement="args.placement">
|
|
146
|
+
<button type="button">Subcontent via slot</button>
|
|
147
|
+
<template #subcontent>
|
|
148
|
+
<p>Optional subcontent via slot, includes <b>HTML</b> <u>tags</u></p>
|
|
149
|
+
</template>
|
|
150
|
+
</CpTooltip>
|
|
151
|
+
</div>
|
|
152
152
|
</div>
|
|
153
153
|
`,
|
|
154
154
|
}),
|
|
155
155
|
}
|
|
156
156
|
|
|
157
|
+
/* -------------------------------------------------------------------------- */
|
|
158
|
+
/* States */
|
|
159
|
+
/* -------------------------------------------------------------------------- */
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* When `disabled` is `true` the tooltip never appears, even on hover.
|
|
163
|
+
*/
|
|
157
164
|
export const Disabled: Story = {
|
|
158
|
-
args: {
|
|
159
|
-
|
|
160
|
-
},
|
|
161
|
-
render: (args) => ({
|
|
165
|
+
args: { disabled: true },
|
|
166
|
+
render: (args: Args) => ({
|
|
162
167
|
components: { CpTooltip },
|
|
163
168
|
setup() {
|
|
164
169
|
return { args }
|
|
@@ -166,7 +171,7 @@ export const Disabled: Story = {
|
|
|
166
171
|
template: `
|
|
167
172
|
<div style="padding: 100px; text-align: center;">
|
|
168
173
|
<CpTooltip v-bind="args" content="You should not see me">
|
|
169
|
-
<div
|
|
174
|
+
<div>Disabled trigger</div>
|
|
170
175
|
</CpTooltip>
|
|
171
176
|
</div>
|
|
172
177
|
`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, ref } from 'vue'
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
4
4
|
|
|
5
5
|
import CpButton from '@/components/CpButton.vue'
|
|
6
6
|
import CpIcon from '@/components/CpIcon.vue'
|
|
@@ -24,6 +24,10 @@ const rowStyle = 'padding: 24px; display: inline-flex; align-items: center; just
|
|
|
24
24
|
|
|
25
25
|
const counterTextStyle = 'font-weight: bold; font-size: 4.5rem; line-height: 1; font-variant-numeric: tabular-nums;'
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Counter transition that animates number changes. Use the +/- buttons
|
|
29
|
+
* (or the `duration` control) to see the slide-in / slide-out behaviour.
|
|
30
|
+
*/
|
|
27
31
|
export const Default: Story = {
|
|
28
32
|
args: {
|
|
29
33
|
duration: 150,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref } from 'vue'
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
4
4
|
|
|
5
5
|
import CpTransitionExpand from '@/components/CpTransitionExpand.vue'
|
|
6
6
|
|
|
@@ -17,6 +17,10 @@ type Story = StoryObj<typeof meta>
|
|
|
17
17
|
|
|
18
18
|
const wrapperStyle = 'display: flex; flex-direction: column; align-items: center; gap: 12px;'
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Animated height expansion. Wrap any element in `<CpTransitionExpand>`
|
|
22
|
+
* and toggle its rendering with `v-if` to smoothly expand/collapse.
|
|
23
|
+
*/
|
|
20
24
|
export const Default: Story = {
|
|
21
25
|
render: () => ({
|
|
22
26
|
components: { CpTransitionExpand },
|
|
@@ -35,14 +39,11 @@ export const Default: Story = {
|
|
|
35
39
|
</CpButton>
|
|
36
40
|
|
|
37
41
|
<CpTransitionExpand>
|
|
38
|
-
<div v-if="isExpanded" style="
|
|
39
|
-
background: #F3F4F6;
|
|
40
|
-
border-radius: 6px;
|
|
41
|
-
">
|
|
42
|
+
<div v-if="isExpanded" style="background: #F3F4F6; border-radius: 6px; padding: 16px;">
|
|
42
43
|
<h3 style="margin: 0 0 8px 0;">Expanded Content</h3>
|
|
43
44
|
<p style="margin: 0;">
|
|
44
|
-
This content
|
|
45
|
-
|
|
45
|
+
This content smoothly expands and collapses. The height transition is handled
|
|
46
|
+
automatically by the CpTransitionExpand component.
|
|
46
47
|
</p>
|
|
47
48
|
</div>
|
|
48
49
|
</CpTransitionExpand>
|
|
@@ -51,6 +52,10 @@ export const Default: Story = {
|
|
|
51
52
|
}),
|
|
52
53
|
}
|
|
53
54
|
|
|
55
|
+
/**
|
|
56
|
+
* The transition works with content of any height — no manual value
|
|
57
|
+
* needed.
|
|
58
|
+
*/
|
|
54
59
|
export const WithLongContent: Story = {
|
|
55
60
|
render: () => ({
|
|
56
61
|
components: { CpTransitionExpand },
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref } from 'vue'
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
4
4
|
import type { MenuItem } from 'primevue/menuitem'
|
|
5
5
|
|
|
6
6
|
import CpButton from '@/components/CpButton.vue'
|
|
@@ -51,6 +51,11 @@ const fabWrapperStyle = {
|
|
|
51
51
|
alignItems: 'flex-end',
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
+
/**
|
|
55
|
+
* Animate list insertions, removals and reorders with FLIP-based
|
|
56
|
+
* transitions. Use the + / shuffle buttons to see the enter, leave and
|
|
57
|
+
* move animations.
|
|
58
|
+
*/
|
|
54
59
|
export const Default: Story = {
|
|
55
60
|
args: {
|
|
56
61
|
disableOnLoad: false,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed, ref } from 'vue'
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
4
4
|
|
|
5
5
|
import CpButton from '@/components/CpButton.vue'
|
|
6
6
|
import CpTransitionSize from '@/components/CpTransitionSize.vue'
|
|
@@ -21,6 +21,10 @@ type Story = StoryObj<typeof meta>
|
|
|
21
21
|
|
|
22
22
|
const wrapperStyle = 'display: flex; flex-direction: column; align-items: center; gap: 12px;'
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* Animate a button's width when its inner label changes. Click the
|
|
26
|
+
* button to swap between a short and a longer label.
|
|
27
|
+
*/
|
|
24
28
|
export const Default: Story = {
|
|
25
29
|
args: {
|
|
26
30
|
type: 'width',
|
|
@@ -50,6 +54,10 @@ export const Default: Story = {
|
|
|
50
54
|
}),
|
|
51
55
|
}
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Height mode — smoothly animates a dialog's body height as the step
|
|
59
|
+
* content (and therefore its size) changes.
|
|
60
|
+
*/
|
|
53
61
|
export const HeightTransition: Story = {
|
|
54
62
|
args: {
|
|
55
63
|
type: 'height',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ref } from 'vue'
|
|
2
2
|
|
|
3
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
3
|
+
import type { Meta, StoryObj } from '@storybook/vue3-vite'
|
|
4
4
|
|
|
5
5
|
import CpButton from '@/components/CpButton.vue'
|
|
6
6
|
import CpTransitionSlide from '@/components/CpTransitionSlide.vue'
|
|
@@ -28,6 +28,10 @@ const wrapperStyle = 'display: flex; flex-direction: column; align-items: center
|
|
|
28
28
|
const panelStyle =
|
|
29
29
|
'min-width: 260px; max-width: 320px; padding: 20px; border-radius: 12px; background: #f3f4f6; text-align: center;'
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* Slide between two panels. The `slideTo` prop controls direction
|
|
33
|
+
* (`top` or `left`) and `mode` follows Vue's `<Transition mode>` rules.
|
|
34
|
+
*/
|
|
31
35
|
export const Toggle: Story = {
|
|
32
36
|
name: 'Toggle',
|
|
33
37
|
args: {
|