@cypress-design/vue-alert 0.1.2 → 0.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/Alert.rootstory.tsx +85 -71
- package/Alert.stories.mdx +1 -1
- package/Alert.vue +77 -61
- package/AlertVue.cy.tsx +1 -1
- package/CHANGELOG.md +6 -0
- package/dist/constants.d.ts +10 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/index.es.mjs +106 -98
- package/dist/index.es.mjs.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/vue/Alert.vue.d.ts +29 -6
- package/dist/vue/Alert.vue.d.ts.map +1 -1
- package/package.json +1 -1
package/Alert.rootstory.tsx
CHANGED
|
@@ -3,29 +3,28 @@ import dedent from 'dedent'
|
|
|
3
3
|
import { ref } from 'vue'
|
|
4
4
|
import Alert from './Alert.vue'
|
|
5
5
|
|
|
6
|
-
export default () =>
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{dedent`Uncaught Error: Error occurred in defineConfig()
|
|
6
|
+
export default () => {
|
|
7
|
+
const displayTimedAlert = ref(false)
|
|
8
|
+
return (
|
|
9
|
+
<div class="flex flex-col p-4 gap-16px">
|
|
10
|
+
<Alert type="error" detailsTitle="Stack trace" data-cy="alert-1">
|
|
11
|
+
{{
|
|
12
|
+
default: () => 'Spec not found',
|
|
13
|
+
body: () => (
|
|
14
|
+
<>
|
|
15
|
+
There is no spec matching the following location:
|
|
16
|
+
<code class="bg-red-100 m-8px rounded px-2px">
|
|
17
|
+
path/to/spec.cy.js
|
|
18
|
+
</code>
|
|
19
|
+
<br />
|
|
20
|
+
<br />
|
|
21
|
+
It is possible that the file has since been moved or deleted.
|
|
22
|
+
Please choose from the list of specs below
|
|
23
|
+
</>
|
|
24
|
+
),
|
|
25
|
+
details: () => (
|
|
26
|
+
<pre class="bg-white rounded border border-red-500 px-16px py-8px overflow-x-auto">
|
|
27
|
+
{dedent`Uncaught Error: Error occurred in defineConfig()
|
|
29
28
|
Trace: add called with 2 and 3
|
|
30
29
|
at sum (/home/dev/Documents/stacktrace.js:2:13)
|
|
31
30
|
at start (/home/dev/Documents/stacktrace.js:11:13)
|
|
@@ -58,53 +57,68 @@ export default () => ({
|
|
|
58
57
|
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
|
|
59
58
|
at Function.Module.runMain (internal/modules/cjs/loader.js:1047:10)
|
|
60
59
|
at internal/main/run_main_module.js:17:11`}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
60
|
+
</pre>
|
|
61
|
+
),
|
|
62
|
+
}}
|
|
63
|
+
</Alert>
|
|
64
|
+
<button
|
|
65
|
+
class="border rounded p-8px"
|
|
66
|
+
onClick={() => (displayTimedAlert.value = true)}
|
|
67
|
+
>
|
|
68
|
+
open alert for 5 seconds
|
|
69
|
+
</button>
|
|
70
|
+
{displayTimedAlert.value && (
|
|
71
|
+
<Alert
|
|
72
|
+
duration={5000}
|
|
73
|
+
onDismiss={() => (displayTimedAlert.value = false)}
|
|
74
|
+
dismissible
|
|
75
|
+
data-cy="alert-2"
|
|
68
76
|
>
|
|
69
|
-
|
|
70
|
-
</button>
|
|
71
|
-
{displayTimedAlert.value && (
|
|
72
|
-
<Alert
|
|
73
|
-
duration={5000}
|
|
74
|
-
onDismiss={() => (displayTimedAlert.value = false)}
|
|
75
|
-
dismissible
|
|
76
|
-
data-cy="alert-2"
|
|
77
|
-
>
|
|
78
|
-
Wait 5 seconds please
|
|
79
|
-
</Alert>
|
|
80
|
-
)}
|
|
81
|
-
<Alert type="success" dismissible data-cy="alert-3">
|
|
82
|
-
{{
|
|
83
|
-
default: () => 'Success with body',
|
|
84
|
-
body: () => 'Success body',
|
|
85
|
-
}}
|
|
86
|
-
</Alert>
|
|
87
|
-
<Alert type="warning" not-rounded>
|
|
88
|
-
Warning
|
|
89
|
-
</Alert>
|
|
90
|
-
<Alert type="neutral">Neutral</Alert>
|
|
91
|
-
<Alert type="error" dismissible class="text-justify" data-cy="alert-4">
|
|
92
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
93
|
-
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad
|
|
94
|
-
minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
95
|
-
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
96
|
-
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
97
|
-
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
98
|
-
culpa qui officia deserunt mollit anim id est laborum.
|
|
77
|
+
Wait 5 seconds please
|
|
99
78
|
</Alert>
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
79
|
+
)}
|
|
80
|
+
<Alert type="success" dismissible data-cy="alert-3">
|
|
81
|
+
{{
|
|
82
|
+
default: () => 'Success with body',
|
|
83
|
+
body: () => 'Success body',
|
|
84
|
+
}}
|
|
85
|
+
</Alert>
|
|
86
|
+
<Alert type="warning" not-rounded>
|
|
87
|
+
Warning
|
|
88
|
+
</Alert>
|
|
89
|
+
<Alert type="neutral">Neutral</Alert>
|
|
90
|
+
<Alert type="error" dismissible class="text-justify" data-cy="alert-4">
|
|
91
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
|
|
92
|
+
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
|
|
93
|
+
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
|
|
94
|
+
commodo consequat. Duis aute irure dolor in reprehenderit in voluptate
|
|
95
|
+
velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint
|
|
96
|
+
occaecat cupidatat non proident, sunt in culpa qui officia deserunt
|
|
97
|
+
mollit anim id est laborum.
|
|
98
|
+
</Alert>
|
|
99
|
+
<Alert type="info">Info</Alert>
|
|
100
|
+
<Alert type="info">
|
|
101
|
+
{{
|
|
102
|
+
default: () => 'Info',
|
|
103
|
+
icon: (props: any) => <IconArrowRight {...props} />,
|
|
104
|
+
}}
|
|
105
|
+
</Alert>
|
|
106
|
+
{(['xs', 'sm', 'md', 'lg'] as const).map((size) => (
|
|
107
|
+
<>
|
|
108
|
+
<Alert type="error" data-cy="alert-size" size={size}>
|
|
109
|
+
{size} - Lorem ipsum dolor sit amet
|
|
110
|
+
</Alert>
|
|
111
|
+
<Alert type="warning" data-cy="alert-size" size={size}>
|
|
112
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do
|
|
113
|
+
eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
|
|
114
|
+
ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
|
|
115
|
+
aliquip ex ea commodo consequat. Duis aute irure dolor in
|
|
116
|
+
reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
|
|
117
|
+
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in
|
|
118
|
+
culpa qui officia deserunt mollit anim id est laborum.
|
|
119
|
+
</Alert>
|
|
120
|
+
</>
|
|
121
|
+
))}
|
|
122
|
+
</div>
|
|
123
|
+
)
|
|
124
|
+
}
|
package/Alert.stories.mdx
CHANGED
package/Alert.vue
CHANGED
|
@@ -1,61 +1,3 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div
|
|
3
|
-
v-if="!dismissed"
|
|
4
|
-
class="overflow-hidden text-left"
|
|
5
|
-
:class="props.notRounded ? undefined : 'rounded'"
|
|
6
|
-
>
|
|
7
|
-
<div class="flex p-16px" :class="typeClasses.headerClass">
|
|
8
|
-
<!-- @slot replace the default left icon here -->
|
|
9
|
-
<slot name="icon" v-bind="computedIconProps">
|
|
10
|
-
<component
|
|
11
|
-
v-if="!props.noIcon && icon"
|
|
12
|
-
:is="icon"
|
|
13
|
-
v-bind="computedIconProps"
|
|
14
|
-
/>
|
|
15
|
-
</slot>
|
|
16
|
-
<div class="flex-1 font-medium">
|
|
17
|
-
<!-- @slot title of the alert -->
|
|
18
|
-
<slot />
|
|
19
|
-
</div>
|
|
20
|
-
<button
|
|
21
|
-
v-if="dismissible"
|
|
22
|
-
class="m-4px ml-8px h-16px"
|
|
23
|
-
@click="dismiss"
|
|
24
|
-
aria-label="Dismiss"
|
|
25
|
-
>
|
|
26
|
-
<IconActionDeleteLarge :stroke-color="typeClasses.iconCloseColor" />
|
|
27
|
-
</button>
|
|
28
|
-
</div>
|
|
29
|
-
<div v-if="slots.body" class="p-16px" :class="typeClasses.bodyClass">
|
|
30
|
-
<!-- @slot body/details of the alert -->
|
|
31
|
-
<slot name="body" />
|
|
32
|
-
</div>
|
|
33
|
-
<details
|
|
34
|
-
v-if="slots.details"
|
|
35
|
-
class="p-16px border-t-1"
|
|
36
|
-
ref="detailsRef"
|
|
37
|
-
:class="[typeClasses.bodyClass, typeClasses.borderClass]"
|
|
38
|
-
>
|
|
39
|
-
<summary
|
|
40
|
-
class="flex font-medium cursor-pointer details-none"
|
|
41
|
-
:class="typeClasses.detailsHeaderClass"
|
|
42
|
-
>
|
|
43
|
-
<IconChevronDownSmall
|
|
44
|
-
:strokeColor="typeClasses.iconChevronColor"
|
|
45
|
-
class="icon my-4px mr-8px transition transform -rotate-90 open:rotate-0"
|
|
46
|
-
/>
|
|
47
|
-
{{ props.detailsTitle }}
|
|
48
|
-
</summary>
|
|
49
|
-
<div ref="contentRef">
|
|
50
|
-
<div class="mt-16px">
|
|
51
|
-
<!--@slot Togglable additional details-->
|
|
52
|
-
<slot name="details" />
|
|
53
|
-
</div>
|
|
54
|
-
</div>
|
|
55
|
-
</details>
|
|
56
|
-
</div>
|
|
57
|
-
</template>
|
|
58
|
-
|
|
59
1
|
<script lang="ts" setup>
|
|
60
2
|
import type { FunctionalComponent, ComputedRef } from 'vue'
|
|
61
3
|
import { computed, useSlots, h, ref, onMounted, onUnmounted } from 'vue'
|
|
@@ -66,7 +8,14 @@ import {
|
|
|
66
8
|
IconCheckmarkOutline,
|
|
67
9
|
} from '@cypress-design/vue-icon'
|
|
68
10
|
import { DetailsAnimation } from '@cypress-design/details-animation'
|
|
69
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
AlertSize,
|
|
13
|
+
alertSizesClasses,
|
|
14
|
+
AlertType,
|
|
15
|
+
defaultAlertSize,
|
|
16
|
+
defaultAlertTitle,
|
|
17
|
+
defaultAlertType,
|
|
18
|
+
} from '../constants'
|
|
70
19
|
import { alertClasses } from '../constants'
|
|
71
20
|
|
|
72
21
|
const dismissed = ref(false)
|
|
@@ -106,10 +55,15 @@ const props = withDefaults(
|
|
|
106
55
|
* Dismiss the alert after a delay (in ms)
|
|
107
56
|
*/
|
|
108
57
|
duration?: number
|
|
58
|
+
/**
|
|
59
|
+
* Size of the alert
|
|
60
|
+
*/
|
|
61
|
+
size?: AlertSize
|
|
109
62
|
}>(),
|
|
110
63
|
{
|
|
111
|
-
type:
|
|
112
|
-
detailsTitle:
|
|
64
|
+
type: defaultAlertType,
|
|
65
|
+
detailsTitle: defaultAlertTitle,
|
|
66
|
+
size: defaultAlertSize,
|
|
113
67
|
}
|
|
114
68
|
)
|
|
115
69
|
|
|
@@ -170,4 +124,66 @@ const icon: ComputedRef<FunctionalComponent | null> = computed(() => {
|
|
|
170
124
|
return null
|
|
171
125
|
}
|
|
172
126
|
})
|
|
127
|
+
|
|
128
|
+
const sizeClasses = computed(() => {
|
|
129
|
+
return alertSizesClasses[props.size]
|
|
130
|
+
})
|
|
173
131
|
</script>
|
|
132
|
+
|
|
133
|
+
<template>
|
|
134
|
+
<div
|
|
135
|
+
v-if="!dismissed"
|
|
136
|
+
class="overflow-hidden text-left"
|
|
137
|
+
:class="props.notRounded ? undefined : 'rounded'"
|
|
138
|
+
>
|
|
139
|
+
<div class="flex" :class="[typeClasses.headerClass, sizeClasses]">
|
|
140
|
+
<!-- @slot replace the default left icon here -->
|
|
141
|
+
<slot name="icon" v-bind="computedIconProps">
|
|
142
|
+
<component
|
|
143
|
+
v-if="!props.noIcon && icon"
|
|
144
|
+
:is="icon"
|
|
145
|
+
v-bind="computedIconProps"
|
|
146
|
+
/>
|
|
147
|
+
</slot>
|
|
148
|
+
<div class="flex-1 font-medium">
|
|
149
|
+
<!-- @slot title of the alert -->
|
|
150
|
+
<slot />
|
|
151
|
+
</div>
|
|
152
|
+
<button
|
|
153
|
+
v-if="dismissible"
|
|
154
|
+
class="m-4px ml-8px h-16px"
|
|
155
|
+
@click="dismiss"
|
|
156
|
+
aria-label="Dismiss"
|
|
157
|
+
>
|
|
158
|
+
<IconActionDeleteLarge :stroke-color="typeClasses.iconCloseColor" />
|
|
159
|
+
</button>
|
|
160
|
+
</div>
|
|
161
|
+
<div v-if="slots.body" class="p-16px" :class="typeClasses.bodyClass">
|
|
162
|
+
<!-- @slot body/details of the alert -->
|
|
163
|
+
<slot name="body" />
|
|
164
|
+
</div>
|
|
165
|
+
<details
|
|
166
|
+
v-if="slots.details"
|
|
167
|
+
class="p-16px border-t-1"
|
|
168
|
+
ref="detailsRef"
|
|
169
|
+
:class="[typeClasses.bodyClass, typeClasses.borderClass]"
|
|
170
|
+
>
|
|
171
|
+
<summary
|
|
172
|
+
class="flex font-medium cursor-pointer details-none"
|
|
173
|
+
:class="typeClasses.detailsHeaderClass"
|
|
174
|
+
>
|
|
175
|
+
<IconChevronDownSmall
|
|
176
|
+
:strokeColor="typeClasses.iconChevronColor"
|
|
177
|
+
class="icon my-4px mr-8px transition transform -rotate-90 open:rotate-0"
|
|
178
|
+
/>
|
|
179
|
+
{{ props.detailsTitle }}
|
|
180
|
+
</summary>
|
|
181
|
+
<div ref="contentRef">
|
|
182
|
+
<div>
|
|
183
|
+
<!--@slot Togglable additional details-->
|
|
184
|
+
<slot name="details" />
|
|
185
|
+
</div>
|
|
186
|
+
</div>
|
|
187
|
+
</details>
|
|
188
|
+
</div>
|
|
189
|
+
</template>
|
package/AlertVue.cy.tsx
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @cypress-design/vue-alert
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#114](https://github.com/cypress-io/cypress-design/pull/114) [`2a6597c`](https://github.com/cypress-io/cypress-design/commit/2a6597c16efc05ffe4ec51ab19cd2d7836a24c5c) Thanks [@elevatebart](https://github.com/elevatebart)! - fix: add sizes to alerts
|
|
8
|
+
|
|
3
9
|
## 0.1.2
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
import type { WindiColor } from '@cypress-design/icon-registry';
|
|
2
2
|
export declare type AlertType = 'info' | 'success' | 'error' | 'warning' | 'neutral';
|
|
3
|
+
export declare const alertSizesClasses: {
|
|
4
|
+
readonly xs: "py-4px px-8px leading-22px text-14px";
|
|
5
|
+
readonly sm: "py-8px px-12px leading-22px text-14px";
|
|
6
|
+
readonly md: "py-12px px-16px leading-24px text-16px";
|
|
7
|
+
readonly lg: "p-16px leading-24px text-16px";
|
|
8
|
+
};
|
|
9
|
+
export declare type AlertSize = keyof typeof alertSizesClasses;
|
|
10
|
+
export declare const defaultAlertSize: AlertSize;
|
|
3
11
|
export declare type AlertClasses = {
|
|
4
12
|
headerClass: string;
|
|
5
13
|
bodyClass: string;
|
|
@@ -10,4 +18,6 @@ export declare type AlertClasses = {
|
|
|
10
18
|
iconChevronColor: WindiColor;
|
|
11
19
|
};
|
|
12
20
|
export declare const alertClasses: Record<AlertType, AlertClasses>;
|
|
21
|
+
export declare const defaultAlertType: AlertType;
|
|
22
|
+
export declare const defaultAlertTitle = "Additional details";
|
|
13
23
|
//# sourceMappingURL=constants.d.ts.map
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,oBAAY,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAA;AAE/D,oBAAY,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,GAAG,SAAS,CAAA;AAC5E,eAAO,MAAM,iBAAiB;;;;;CAKpB,CAAA;AAEV,oBAAY,SAAS,GAAG,MAAM,OAAO,iBAAiB,CAAA;AACtD,eAAO,MAAM,gBAAgB,EAAE,SAAgB,CAAA;AAE/C,oBAAY,YAAY,GAAG;IACzB,WAAW,EAAE,MAAM,CAAA;IACnB,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,kBAAkB,EAAE,MAAM,CAAA;IAC1B,cAAc,EAAE,UAAU,CAAA;IAC1B,SAAS,CAAC,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,UAAU,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,YAAY,CA6DxD,CAAA;AAED,eAAO,MAAM,gBAAgB,EAAE,SAAkB,CAAA;AAEjD,eAAO,MAAM,iBAAiB,uBAAuB,CAAA"}
|