@citizenplane/pimp 16.0.2 → 16.1.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 +343 -311
- package/dist/pimp.umd.js +21 -21
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/components/CpAlert.vue +38 -30
- package/src/components/CpHeading.vue +4 -5
- package/src/components/CpText.vue +141 -0
- package/src/components/index.ts +2 -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 +187 -158
- package/src/stories/CpAccordionGroup.stories.ts +50 -94
- package/src/stories/CpAirlineLogo.stories.ts +49 -28
- package/src/stories/CpAlert.stories.ts +194 -157
- package/src/stories/CpBadge.stories.ts +259 -193
- package/src/stories/CpButton.stories.ts +257 -426
- package/src/stories/CpCheckbox.stories.ts +101 -29
- package/src/stories/CpContextualMenu.stories.ts +9 -8
- package/src/stories/CpDate.stories.ts +52 -25
- package/src/stories/CpDatepicker.stories.ts +57 -88
- package/src/stories/CpDialog.stories.ts +22 -1
- package/src/stories/CpHeading.stories.ts +59 -20
- package/src/stories/CpIcon.stories.ts +98 -31
- package/src/stories/CpInput.stories.ts +142 -67
- package/src/stories/CpItemActions.stories.ts +22 -27
- package/src/stories/CpLoader.stories.ts +54 -6
- package/src/stories/CpMenuItem.stories.ts +52 -26
- package/src/stories/CpMultiselect.stories.ts +52 -71
- package/src/stories/CpPartnerBadge.stories.ts +53 -74
- package/src/stories/CpRadio.stories.ts +44 -48
- package/src/stories/CpRadioGroup.stories.ts +46 -39
- package/src/stories/CpSelect.stories.ts +98 -39
- package/src/stories/CpSelectMenu.stories.ts +49 -57
- package/src/stories/CpSelectableButton.stories.ts +170 -81
- package/src/stories/CpSwitch.stories.ts +135 -133
- package/src/stories/CpTable.stories.ts +54 -1
- package/src/stories/CpTableEmptyState.stories.ts +11 -7
- package/src/stories/CpTabs.stories.ts +22 -4
- package/src/stories/CpTelInput.stories.ts +25 -23
- package/src/stories/CpText.stories.ts +131 -0
- package/src/stories/CpTextarea.stories.ts +59 -23
- package/src/stories/CpToast.stories.ts +53 -103
- package/src/stories/CpTooltip.stories.ts +82 -77
- package/src/stories/CpTransitionCounter.stories.ts +4 -0
- package/src/stories/CpTransitionExpand.stories.ts +11 -6
- package/src/stories/CpTransitionListItems.stories.ts +5 -0
- package/src/stories/CpTransitionSize.stories.ts +8 -0
- package/src/stories/CpTransitionSlide.stories.ts +4 -0
- package/src/stories/CpTransitionTabContent.stories.ts +4 -0
- 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
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
1
|
+
import type { Args, Meta, StoryObj } from '@storybook/vue3'
|
|
2
2
|
|
|
3
3
|
import CpTelInput from '@/components/CpTelInput.vue'
|
|
4
4
|
|
|
5
|
+
const telInputSizes = ['md', 'lg'] as const
|
|
6
|
+
|
|
5
7
|
const meta = {
|
|
6
|
-
title: '
|
|
8
|
+
title: 'Molecules/CpTelInput',
|
|
7
9
|
component: CpTelInput,
|
|
8
10
|
argTypes: {
|
|
9
11
|
telModel: {
|
|
@@ -12,7 +14,7 @@ const meta = {
|
|
|
12
14
|
},
|
|
13
15
|
size: {
|
|
14
16
|
control: 'select',
|
|
15
|
-
options:
|
|
17
|
+
options: telInputSizes,
|
|
16
18
|
description: 'The size of the input',
|
|
17
19
|
},
|
|
18
20
|
},
|
|
@@ -21,28 +23,28 @@ const meta = {
|
|
|
21
23
|
export default meta
|
|
22
24
|
type Story = StoryObj<typeof meta>
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const defaultRender = (args: Args) => ({
|
|
27
|
+
components: { CpTelInput },
|
|
28
|
+
setup() {
|
|
29
|
+
return { args }
|
|
27
30
|
},
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
template: '<CpTelInput v-bind="args" />',
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Default telephone input with a country selector. Use the controls to
|
|
36
|
+
* experiment with each prop in isolation.
|
|
37
|
+
*/
|
|
38
|
+
export const Default: Story = {
|
|
39
|
+
args: { telModel: '' },
|
|
40
|
+
render: defaultRender,
|
|
35
41
|
}
|
|
36
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Pre-select a country via the `defaultCountry` ISO-2 code (e.g. `us`,
|
|
45
|
+
* `fr`, `gb`).
|
|
46
|
+
*/
|
|
37
47
|
export const WithDefaultCountry: Story = {
|
|
38
|
-
args: {
|
|
39
|
-
|
|
40
|
-
},
|
|
41
|
-
render: (args) => ({
|
|
42
|
-
components: { CpTelInput },
|
|
43
|
-
setup() {
|
|
44
|
-
return { args }
|
|
45
|
-
},
|
|
46
|
-
template: `<CpTelInput v-bind="args" />`,
|
|
47
|
-
}),
|
|
48
|
+
args: { defaultCountry: 'us' },
|
|
49
|
+
render: defaultRender,
|
|
48
50
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Args, Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
|
|
3
|
+
import CpText from '@/components/CpText.vue'
|
|
4
|
+
import type { CpTextSize, CpTextWeight } from '@/components/CpText.vue'
|
|
5
|
+
|
|
6
|
+
import { docLabelStyle } from '@/stories/documentationStyles'
|
|
7
|
+
|
|
8
|
+
const textSizes = [
|
|
9
|
+
'xs',
|
|
10
|
+
'sm',
|
|
11
|
+
'md',
|
|
12
|
+
'lg',
|
|
13
|
+
'xl',
|
|
14
|
+
'2xl',
|
|
15
|
+
'3xl',
|
|
16
|
+
'4xl',
|
|
17
|
+
'5xl',
|
|
18
|
+
'6xl',
|
|
19
|
+
'7xl',
|
|
20
|
+
'8xl',
|
|
21
|
+
'9xl',
|
|
22
|
+
] as const satisfies readonly CpTextSize[]
|
|
23
|
+
|
|
24
|
+
const weights = [400, 500, 600, 700] as const satisfies readonly CpTextWeight[]
|
|
25
|
+
|
|
26
|
+
const rowStyle = 'display: grid; grid-template-columns: 56px 1fr; gap: 16px; align-items: center;'
|
|
27
|
+
|
|
28
|
+
const sizesRowStyle = 'display: flex; align-items: center; gap: 16px; width: max-content;'
|
|
29
|
+
|
|
30
|
+
const meta = {
|
|
31
|
+
title: 'Atoms/CpText',
|
|
32
|
+
component: CpText,
|
|
33
|
+
parameters: {
|
|
34
|
+
docs: {
|
|
35
|
+
description: {
|
|
36
|
+
component:
|
|
37
|
+
'Typography primitive for body and UI copy. Pairs each `size` with the matching `--cp-text-size-*` and `--cp-line-height-*` design tokens. Override the root element with `tag` (defaults to `p`).',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
argTypes: {
|
|
42
|
+
tag: {
|
|
43
|
+
control: 'text',
|
|
44
|
+
description: 'Root HTML tag (default: `p`).',
|
|
45
|
+
},
|
|
46
|
+
size: {
|
|
47
|
+
control: 'select',
|
|
48
|
+
options: textSizes,
|
|
49
|
+
description: 'Scale step from `xs` through `9xl`; maps to typography CSS variables.',
|
|
50
|
+
},
|
|
51
|
+
weight: {
|
|
52
|
+
control: 'select',
|
|
53
|
+
options: [undefined, ...weights],
|
|
54
|
+
description: 'Font weight from 400 to 700.',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
} satisfies Meta<typeof CpText>
|
|
58
|
+
|
|
59
|
+
export default meta
|
|
60
|
+
type Story = StoryObj<typeof meta>
|
|
61
|
+
|
|
62
|
+
export const Default: Story = {
|
|
63
|
+
args: {
|
|
64
|
+
size: 'md',
|
|
65
|
+
},
|
|
66
|
+
render: (args: Args) => ({
|
|
67
|
+
components: { CpText },
|
|
68
|
+
setup() {
|
|
69
|
+
return { args }
|
|
70
|
+
},
|
|
71
|
+
template: `
|
|
72
|
+
<div style="padding: 20px;">
|
|
73
|
+
<CpText v-bind="args">Body text using the size and line-height tokens.</CpText>
|
|
74
|
+
</div>
|
|
75
|
+
`,
|
|
76
|
+
}),
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const Sizes: Story = {
|
|
80
|
+
parameters: { controls: { disable: true }, layout: 'padded' },
|
|
81
|
+
render: () => ({
|
|
82
|
+
components: { CpText },
|
|
83
|
+
setup() {
|
|
84
|
+
return { textSizes, sizesRowStyle, docLabelStyle }
|
|
85
|
+
},
|
|
86
|
+
template: `
|
|
87
|
+
<div style="display: flex; flex-direction: column; gap: 12px; overflow-x: auto; max-width: 100%;">
|
|
88
|
+
<div v-for="size in textSizes" :key="size" :style="sizesRowStyle">
|
|
89
|
+
<span :style="docLabelStyle + ' flex: 0 0 56px;'">{{ size }}</span>
|
|
90
|
+
<CpText :size="size" style="white-space: nowrap;">A design system offers guidelines and components for consistent visuals and better user experience.</CpText>
|
|
91
|
+
</div>
|
|
92
|
+
</div>
|
|
93
|
+
`,
|
|
94
|
+
}),
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export const Weights: Story = {
|
|
98
|
+
parameters: { controls: { disable: true } },
|
|
99
|
+
render: () => ({
|
|
100
|
+
components: { CpText },
|
|
101
|
+
setup() {
|
|
102
|
+
return { weights, rowStyle, docLabelStyle }
|
|
103
|
+
},
|
|
104
|
+
template: `
|
|
105
|
+
<div style="padding: 20px; display: flex; flex-direction: column; gap: 12px;">
|
|
106
|
+
<div v-for="w in weights" :key="w" :style="rowStyle">
|
|
107
|
+
<span :style="docLabelStyle">{{ w }}</span>
|
|
108
|
+
<CpText :weight="w">Create a harmonious user experience</CpText>
|
|
109
|
+
</div>
|
|
110
|
+
</div>
|
|
111
|
+
`,
|
|
112
|
+
}),
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export const CustomTag: Story = {
|
|
116
|
+
args: {
|
|
117
|
+
tag: 'span',
|
|
118
|
+
size: 'sm',
|
|
119
|
+
},
|
|
120
|
+
render: (args: Args) => ({
|
|
121
|
+
components: { CpText },
|
|
122
|
+
setup() {
|
|
123
|
+
return { args }
|
|
124
|
+
},
|
|
125
|
+
template: `
|
|
126
|
+
<div style="padding: 20px;">
|
|
127
|
+
<p>Inline text: <CpText v-bind="args">styled snippet</CpText> inside a paragraph.</p>
|
|
128
|
+
</div>
|
|
129
|
+
`,
|
|
130
|
+
}),
|
|
131
|
+
}
|
|
@@ -4,8 +4,12 @@ import type { Meta, StoryObj } from '@storybook/vue3'
|
|
|
4
4
|
|
|
5
5
|
import CpTextarea from '@/components/CpTextarea.vue'
|
|
6
6
|
|
|
7
|
+
import { docCellStyle, docLabelStyle, docRowColumnStyle } from '@/stories/documentationStyles'
|
|
8
|
+
|
|
9
|
+
const textareaStackStyle = `${docCellStyle} width: 100%; max-width: 360px;`
|
|
10
|
+
|
|
7
11
|
const meta = {
|
|
8
|
-
title: '
|
|
12
|
+
title: 'Atoms/CpTextarea',
|
|
9
13
|
component: CpTextarea,
|
|
10
14
|
argTypes: {
|
|
11
15
|
modelValue: {
|
|
@@ -50,6 +54,9 @@ const meta = {
|
|
|
50
54
|
export default meta
|
|
51
55
|
type Story = StoryObj<typeof meta>
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* Default textarea. Use the controls to experiment with each prop in isolation.
|
|
59
|
+
*/
|
|
53
60
|
export const Default: Story = {
|
|
54
61
|
args: {
|
|
55
62
|
label: 'Textarea Label',
|
|
@@ -64,37 +71,63 @@ export const Default: Story = {
|
|
|
64
71
|
},
|
|
65
72
|
template: `
|
|
66
73
|
<div style="max-width: 400px; padding: 20px;">
|
|
67
|
-
<CpTextarea
|
|
68
|
-
v-model="value"
|
|
69
|
-
v-bind="args"
|
|
70
|
-
/>
|
|
74
|
+
<CpTextarea v-model="value" v-bind="args" />
|
|
71
75
|
</div>
|
|
72
76
|
`,
|
|
73
77
|
}),
|
|
74
78
|
}
|
|
75
79
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
isInvalid: true,
|
|
80
|
-
errorMessage: 'This field is required',
|
|
81
|
-
},
|
|
82
|
-
}
|
|
80
|
+
/* -------------------------------------------------------------------------- */
|
|
81
|
+
/* States */
|
|
82
|
+
/* -------------------------------------------------------------------------- */
|
|
83
83
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
},
|
|
84
|
+
/**
|
|
85
|
+
* Default, required, disabled and invalid states compared side by side.
|
|
86
|
+
*/
|
|
87
|
+
export const States: Story = {
|
|
88
|
+
parameters: { controls: { disable: true } },
|
|
89
|
+
render: () => ({
|
|
90
|
+
components: { CpTextarea },
|
|
91
|
+
setup() {
|
|
92
|
+
const value = ref('')
|
|
93
|
+
return { value, docRowColumnStyle, textareaStackStyle, docLabelStyle }
|
|
94
|
+
},
|
|
95
|
+
template: `
|
|
96
|
+
<div :style="docRowColumnStyle">
|
|
97
|
+
<div :style="textareaStackStyle">
|
|
98
|
+
<span :style="docLabelStyle">Default</span>
|
|
99
|
+
<CpTextarea v-model="value" label="Textarea label" placeholder="Enter your message here" />
|
|
100
|
+
</div>
|
|
101
|
+
<div :style="textareaStackStyle">
|
|
102
|
+
<span :style="docLabelStyle">Required</span>
|
|
103
|
+
<CpTextarea v-model="value" label="Textarea label" placeholder="Enter your message here" :required="true" />
|
|
104
|
+
</div>
|
|
105
|
+
<div :style="textareaStackStyle">
|
|
106
|
+
<span :style="docLabelStyle">Disabled</span>
|
|
107
|
+
<CpTextarea v-model="value" label="Textarea label" placeholder="Enter your message here" :disabled="true" />
|
|
108
|
+
</div>
|
|
109
|
+
<div :style="textareaStackStyle">
|
|
110
|
+
<span :style="docLabelStyle">Invalid</span>
|
|
111
|
+
<CpTextarea
|
|
112
|
+
v-model="value"
|
|
113
|
+
label="Textarea label"
|
|
114
|
+
placeholder="Enter your message here"
|
|
115
|
+
:is-invalid="true"
|
|
116
|
+
error-message="This field is required"
|
|
117
|
+
/>
|
|
118
|
+
</div>
|
|
119
|
+
</div>
|
|
120
|
+
`,
|
|
121
|
+
}),
|
|
89
122
|
}
|
|
90
123
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
disabled: true,
|
|
95
|
-
},
|
|
96
|
-
}
|
|
124
|
+
/* -------------------------------------------------------------------------- */
|
|
125
|
+
/* Variants */
|
|
126
|
+
/* -------------------------------------------------------------------------- */
|
|
97
127
|
|
|
128
|
+
/**
|
|
129
|
+
* Enforce a character limit; a counter is shown below the field.
|
|
130
|
+
*/
|
|
98
131
|
export const WithMaxLength: Story = {
|
|
99
132
|
args: {
|
|
100
133
|
...Default.args,
|
|
@@ -104,6 +137,9 @@ export const WithMaxLength: Story = {
|
|
|
104
137
|
},
|
|
105
138
|
}
|
|
106
139
|
|
|
140
|
+
/**
|
|
141
|
+
* Adjust the number of visible rows through the `rows` prop.
|
|
142
|
+
*/
|
|
107
143
|
export const CustomRows: Story = {
|
|
108
144
|
args: {
|
|
109
145
|
...Default.args,
|
|
@@ -7,13 +7,24 @@ import { CpToastTypes } from '@/constants/CpToastTypes'
|
|
|
7
7
|
|
|
8
8
|
import CpToast from '@/components/CpToast.vue'
|
|
9
9
|
|
|
10
|
+
const toastPositions = [
|
|
11
|
+
'center',
|
|
12
|
+
'top-left',
|
|
13
|
+
'top-center',
|
|
14
|
+
'top-right',
|
|
15
|
+
'bottom-left',
|
|
16
|
+
'bottom-center',
|
|
17
|
+
'bottom-right',
|
|
18
|
+
] as const
|
|
19
|
+
|
|
10
20
|
const meta: Meta<typeof CpToast> = {
|
|
11
|
-
title: '
|
|
21
|
+
title: 'Molecules/CpToast',
|
|
12
22
|
component: CpToast,
|
|
13
23
|
argTypes: {
|
|
14
24
|
position: {
|
|
15
25
|
control: { type: 'select' },
|
|
16
|
-
options:
|
|
26
|
+
options: toastPositions,
|
|
27
|
+
description: 'Where to anchor the toast stack on the screen',
|
|
17
28
|
},
|
|
18
29
|
},
|
|
19
30
|
args: {
|
|
@@ -27,7 +38,11 @@ export default meta
|
|
|
27
38
|
|
|
28
39
|
type Story = StoryObj<typeof CpToast>
|
|
29
40
|
|
|
30
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Trigger toasts of every severity using the `useToast()` composable.
|
|
43
|
+
* Buttons in the canvas call `toast.add()` with a different `severity`.
|
|
44
|
+
*/
|
|
45
|
+
export const Severities: Story = {
|
|
31
46
|
render: (args) => ({
|
|
32
47
|
components: { CpToast },
|
|
33
48
|
setup() {
|
|
@@ -35,111 +50,50 @@ export const Default: Story = {
|
|
|
35
50
|
|
|
36
51
|
const baseOptions = {
|
|
37
52
|
severity: CpToastTypes.SECONDARY,
|
|
38
|
-
summary:
|
|
53
|
+
summary: "Hello i'm a cpToast!",
|
|
39
54
|
detail: 'This is a cpToast description.',
|
|
40
55
|
enableHaptics: true,
|
|
41
56
|
}
|
|
42
57
|
|
|
43
|
-
const
|
|
58
|
+
const notify = (severity: string) => toast.add({ ...baseOptions, severity })
|
|
44
59
|
|
|
45
|
-
|
|
46
|
-
toast.add({
|
|
47
|
-
...baseOptions,
|
|
48
|
-
severity: CpToastTypes.INFO,
|
|
49
|
-
})
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const notifyError = () => {
|
|
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 }
|
|
60
|
+
return { args, notify }
|
|
72
61
|
},
|
|
73
62
|
template: `
|
|
74
63
|
<div style="padding: 16px;">
|
|
75
|
-
|
|
76
64
|
<CpToast v-bind="args" />
|
|
77
65
|
|
|
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>
|
|
66
|
+
<div style="display: flex; gap: 12px; align-items: center; flex-wrap: wrap;">
|
|
67
|
+
<button type="button" @click="notify('secondary')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Secondary</button>
|
|
68
|
+
<button type="button" @click="notify('info')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Info</button>
|
|
69
|
+
<button type="button" @click="notify('success')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Success</button>
|
|
70
|
+
<button type="button" @click="notify('warning')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Warning</button>
|
|
71
|
+
<button type="button" @click="notify('error')" style="padding: 8px 12px; border-radius: 8px; border: 1px solid #ddd; cursor: pointer;">Error</button>
|
|
118
72
|
</div>
|
|
119
73
|
|
|
120
|
-
<p style="margin-top:12px; color
|
|
121
|
-
|
|
74
|
+
<p style="margin-top: 12px; color: #666;">
|
|
75
|
+
Toasts are triggered via <code>useToast()</code>.
|
|
122
76
|
</p>
|
|
123
77
|
</div>
|
|
124
78
|
`,
|
|
125
79
|
}),
|
|
126
80
|
}
|
|
127
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Toasts with a `life` (auto-close) duration can optionally render a
|
|
84
|
+
* countdown bar via the `showTimer` option.
|
|
85
|
+
*/
|
|
128
86
|
export const WithTimer: Story = {
|
|
129
|
-
args: {
|
|
130
|
-
...Default.args,
|
|
131
|
-
},
|
|
132
87
|
render: (args) => ({
|
|
133
88
|
components: { CpToast },
|
|
134
89
|
setup() {
|
|
135
90
|
const toast = useToast()
|
|
136
|
-
|
|
137
91
|
const showTimer = ref(false)
|
|
138
92
|
|
|
139
93
|
const notifyWithTimer = () => {
|
|
140
94
|
toast.add({
|
|
141
95
|
severity: CpToastTypes.INFO,
|
|
142
|
-
summary: "Hello i'm a cpToast with a timer
|
|
96
|
+
summary: "Hello i'm a cpToast with a timer!",
|
|
143
97
|
detail: 'This is a cpToast description.',
|
|
144
98
|
life: 2500,
|
|
145
99
|
showTimer: showTimer.value,
|
|
@@ -151,20 +105,21 @@ export const WithTimer: Story = {
|
|
|
151
105
|
template: `
|
|
152
106
|
<div style="padding: 16px;">
|
|
153
107
|
<CpToast v-bind="args" />
|
|
154
|
-
|
|
155
108
|
<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
|
|
109
|
+
<div style="margin-top: 24px;">
|
|
110
|
+
<cp-switch v-model="showTimer" label="Show timer bar?" />
|
|
158
111
|
</div>
|
|
159
112
|
</div>
|
|
160
113
|
`,
|
|
161
114
|
}),
|
|
162
115
|
}
|
|
163
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Pass `primaryAction` / `secondaryAction` to render buttons inside the
|
|
119
|
+
* toast. Each action exposes a label, optional icons and an `onClick`
|
|
120
|
+
* callback.
|
|
121
|
+
*/
|
|
164
122
|
export const WithActions: Story = {
|
|
165
|
-
args: {
|
|
166
|
-
...Default.args,
|
|
167
|
-
},
|
|
168
123
|
render: (args) => ({
|
|
169
124
|
components: { CpToast },
|
|
170
125
|
setup() {
|
|
@@ -173,21 +128,17 @@ export const WithActions: Story = {
|
|
|
173
128
|
const notifyWithActions = () => {
|
|
174
129
|
toast.add({
|
|
175
130
|
severity: CpToastTypes.INFO,
|
|
176
|
-
summary: "Hello i'm a cpToast with actions
|
|
131
|
+
summary: "Hello i'm a cpToast with actions!",
|
|
177
132
|
detail: 'This is a cpToast description.',
|
|
178
133
|
primaryAction: {
|
|
179
134
|
label: 'Primary action',
|
|
180
135
|
leadingIcon: 'user',
|
|
181
|
-
onClick: () =>
|
|
182
|
-
console.log('Primary action clicked')
|
|
183
|
-
},
|
|
136
|
+
onClick: () => console.log('Primary action clicked'),
|
|
184
137
|
},
|
|
185
138
|
secondaryAction: {
|
|
186
139
|
label: 'Secondary action',
|
|
187
140
|
trailingIcon: 'arrow-right',
|
|
188
|
-
onClick: () =>
|
|
189
|
-
console.log('Secondary action clicked')
|
|
190
|
-
},
|
|
141
|
+
onClick: () => console.log('Secondary action clicked'),
|
|
191
142
|
},
|
|
192
143
|
})
|
|
193
144
|
}
|
|
@@ -197,37 +148,36 @@ export const WithActions: Story = {
|
|
|
197
148
|
template: `
|
|
198
149
|
<div style="padding: 16px;">
|
|
199
150
|
<CpToast v-bind="args" />
|
|
200
|
-
|
|
201
151
|
<cp-button @click="notifyWithActions">Show toast with actions</cp-button>
|
|
202
152
|
</div>
|
|
203
153
|
`,
|
|
204
154
|
}),
|
|
205
155
|
}
|
|
206
156
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
157
|
+
/**
|
|
158
|
+
* The toast stack is positioned via the `position` prop on the
|
|
159
|
+
* `<CpToast>` mount point. Update the control to try every anchor.
|
|
160
|
+
*/
|
|
161
|
+
export const Positions: Story = {
|
|
211
162
|
render: (args) => ({
|
|
212
163
|
components: { CpToast },
|
|
213
164
|
setup() {
|
|
214
165
|
const toast = useToast()
|
|
215
166
|
|
|
216
|
-
const
|
|
167
|
+
const notify = () => {
|
|
217
168
|
toast.add({
|
|
218
169
|
severity: CpToastTypes.INFO,
|
|
219
|
-
summary: "Hello i'm a cpToast
|
|
170
|
+
summary: "Hello i'm a cpToast!",
|
|
220
171
|
detail: 'This is a cpToast description.',
|
|
221
172
|
})
|
|
222
173
|
}
|
|
223
174
|
|
|
224
|
-
return { args,
|
|
175
|
+
return { args, notify }
|
|
225
176
|
},
|
|
226
177
|
template: `
|
|
227
178
|
<div style="padding: 16px;">
|
|
228
179
|
<CpToast v-bind="args" />
|
|
229
|
-
|
|
230
|
-
<cp-button @click="notifyWithPositions">Show toast with positions</cp-button>
|
|
180
|
+
<cp-button @click="notify">Show toast</cp-button>
|
|
231
181
|
</div>
|
|
232
182
|
`,
|
|
233
183
|
}),
|