Skip to content

Commit 1062847

Browse files
Rajdeep ChandraRajdeep Chandra
andauthored
fix(alert-dialog): add Alert Dialog package (#3501)
* chore: first commit for alertdialog * chore: added config for alert dialog * chore: added spectrum-config class attributes * chore: added alert dialog variants * chore: added alert dialog variants * chore: updated variants * chore: added new alertdialog version * chore: removed dialog dependency * chore: added button variant * chore: added storybook * chore: added storybook for scroll variant * chore: added variant tests * chore: updated hash * chore: reverting unused code * chore: bump dependencies version * chore: alert dialog alignment issue * chore: updated golden hash * test: testing * chore: new golden hash * fix: test and css * fix: add golden hash for VRT * chore: removed sp dialog with alert dialog base * fix: css on scroll * fix: updated test case * fix: import fix * fix: sp alert dialog base update in storybook * chore: update icon package for alert icon css * fix: centering issue fix from modal * chore: update golden image hash * chore: update golden image hash * fix: updated tests * chore: update golden hash * test: updated test cases * chore: removed unused imports * chore: adding yarn.lock * fix: updated stories * chore: bump tokens version in styles * chore: update golden image hash * chore: update golden image hash * chore: updated alert dialog wrapper * chore: updated tests * fix: overlay trigger attribute fixes after update * fix: updated version in package.json * fix: updated tokens version * fix: updated tokens version * fix: added open attribute in sp-alert-dialog-wrapper * chore: adding tokens css * chore: golden hash * chore: updated storybook * chore: updated storybook * test: secondary test case added for buttons * fix: css changes in alert dialog, button-group and icon * fix: updated content in readme and toggle button text * chore: updated golden hash * fix: update golden hash * chore: removed alert wrapper * chore: update alert dialog dependency * test: updated alert dialog unit tests * chore: updated golden image cache * chore: removed scroll variant and update readme * chore: inverting the class hierarchy * chore: removed scroll variant * chore: update golden image cache * chore: added alert dialog dependency in dialog * chore: deps update @spectrum-web-components/alert-dialog to ^0.0.1 --------- Co-authored-by: Rajdeep Chandra <rajdeepc@adobe.com>
1 parent 89f3c4b commit 1062847

27 files changed

+1178
-163
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ executors:
1010
parameters:
1111
current_golden_images_hash:
1212
type: string
13-
default: 948872240fa9b5aab9c814086e0dfd4c9fcba423
13+
default: dde875e38aff1cbbb5eea450b92080b23bd6e79d
1414
wireit_cache_name:
1515
type: string
1616
default: wireit

packages/alert-dialog/.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
stories
2+
test

packages/alert-dialog/README.md

Lines changed: 203 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,203 @@
1+
## Description
2+
3+
`sp-alert-dialog` displays important information that users need to acknowledge. When used directly the `sp-alert-dialog` element surfaces a `slot` based API for deep customization of the content to be included in the overlay.
4+
5+
### Usage
6+
7+
[![See it on NPM!](https://img.shields.io/npm/v/@spectrum-web-components/alert-dialog?style=for-the-badge)](https://www.npmjs.com/package/@spectrum-web-components/alert-dialog)
8+
[![How big is this package in your project?](https://img.shields.io/bundlephobia/minzip/@spectrum-web-components/alert-dialog?style=for-the-badge)](https://bundlephobia.com/result?p=@spectrum-web-components/alert-dialog)
9+
10+
```
11+
yarn add @spectrum-web-components/alert-dialog
12+
```
13+
14+
Import the side effectful registration of `<sp-alert-dialog>` via:
15+
16+
```
17+
import '@spectrum-web-components/alert-dialog/sp-alert-dialog.js';
18+
```
19+
20+
When looking to leverage the `AlertDialog` base class as a type and/or for extension purposes, do so via:
21+
22+
```
23+
import { AlertDialog } from '@spectrum-web-components/alert-dialog';
24+
```
25+
26+
## Variants
27+
28+
### Confirmation
29+
30+
This is the default variant for alert dialogs. Use a confirmation variant for asking a user to confirm a choice.
31+
32+
```html
33+
<sp-alert-dialog variant="confirmation">
34+
<h2 slot="heading">Disclaimer</h2>
35+
Smart filters are nondestructive and will preserve your original images.
36+
<sp-button
37+
slot="button"
38+
id="cancelButton"
39+
variant="secondary"
40+
treatment="outline"
41+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
42+
>
43+
Cancel
44+
</sp-button>
45+
<sp-button
46+
slot="button"
47+
id="confirmButton"
48+
variant="accent"
49+
treatment="fill"
50+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
51+
>
52+
Enable
53+
</sp-button>
54+
</sp-alert-dialog>
55+
```
56+
57+
### Information
58+
59+
Information alert dialogs communicate important information that a user needs to acknowledge. Before using this kind of alert dialog, make sure it’s the appropriate communication channel for the message instead of a toast or a more lightweight messaging option.
60+
61+
```html
62+
<sp-alert-dialog variant="information">
63+
<h2 slot="heading">Connect to wifi</h2>
64+
Please connect to wifi to sync your projects or go to Settings to change
65+
your preferences.
66+
<sp-button
67+
slot="button"
68+
id="cancelButton"
69+
variant="secondary"
70+
treatment="outline"
71+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
72+
>
73+
Cancel
74+
</sp-button>
75+
<sp-button
76+
slot="button"
77+
id="confirmButton"
78+
variant="primary"
79+
treatment="outline"
80+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
81+
>
82+
Continue
83+
</sp-button>
84+
</sp-alert-dialog>
85+
```
86+
87+
### Warning
88+
89+
Warning alert dialogs communicate important information to users in relation to an issue that needs to be acknowledged, but does not block the user from moving forward.
90+
91+
```html
92+
<sp-alert-dialog variant="warning">
93+
<h2 slot="heading">Unverified format</h2>
94+
This format has not been verified and may not be viewable for some users. Do
95+
you want to continue publishing?
96+
<sp-button
97+
slot="button"
98+
id="cancelButton"
99+
variant="secondary"
100+
treatment="outline"
101+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
102+
>
103+
Cancel
104+
</sp-button>
105+
<sp-button
106+
slot="button"
107+
id="confirmButton"
108+
variant="primary"
109+
treatment="outline"
110+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
111+
>
112+
Continue
113+
</sp-button>
114+
</sp-alert-dialog>
115+
```
116+
117+
### Error
118+
119+
Error alert dialogs communicate critical information about an issue that a user needs to acknowledge.
120+
121+
```html
122+
<sp-alert-dialog variant="error">
123+
<h2 slot="heading">Unable to share</h2>
124+
An error occured while sharing your project. Please verify the email address
125+
and try again.
126+
<sp-button
127+
slot="button"
128+
id="confirmButton"
129+
variant="primary"
130+
treatment="outline"
131+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
132+
>
133+
Continue
134+
</sp-button>
135+
</sp-alert-dialog>
136+
```
137+
138+
### Destructive
139+
140+
Destructive alert dialogs are for when a user needs to confirm an action that will impact their data or experience in a potentially negative way, such as deleting files or contacts.
141+
142+
```html
143+
<sp-alert-dialog variant="destructive">
144+
<h2 slot="heading">Delete 3 documents?</h2>
145+
Are you sure you want to delete the 3 selected documents?
146+
<sp-button
147+
slot="button"
148+
id="cancelButton"
149+
variant="secondary"
150+
treatment="outline"
151+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
152+
>
153+
Cancel
154+
</sp-button>
155+
<sp-button
156+
slot="button"
157+
id="confirmButton"
158+
variant="negative"
159+
treatment="fill"
160+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
161+
>
162+
Delete
163+
</sp-button>
164+
</sp-alert-dialog>
165+
```
166+
167+
### Secondary Button
168+
169+
An alert dialog can have a total of 3 buttons if the secondary outline button label is defined.
170+
171+
```html
172+
<sp-alert-dialog variant="secondary">
173+
<h2 slot="heading">Rate this app</h2>
174+
If you enjoy our app, would you mind taking a moment to rate it?
175+
<sp-button
176+
slot="button"
177+
id="secondaryButton"
178+
variant="secondary"
179+
treatment="outline"
180+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
181+
>
182+
No, thanks
183+
</sp-button>
184+
<sp-button
185+
slot="button"
186+
id="cancelButton"
187+
variant="secondary"
188+
treatment="outline"
189+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
190+
>
191+
Remind me later
192+
</sp-button>
193+
<sp-button
194+
slot="button"
195+
id="confirmButton"
196+
variant="primary"
197+
treatment="outline"
198+
onclick="this.dispatchEvent(new Event('close', { bubbles: true, composed: true }));"
199+
>
200+
Rate now
201+
</sp-button>
202+
</sp-alert-dialog>
203+
```

packages/alert-dialog/exports.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"./src/*": "./src/*",
3+
"./sp-alert-dialog.js": "./sp-alert-dialog.js"
4+
}

packages/alert-dialog/package.json

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
{
2+
"name": "@spectrum-web-components/alert-dialog",
3+
"version": "0.0.1",
4+
"publishConfig": {
5+
"access": "public"
6+
},
7+
"description": "Web component implementation of a Spectrum design AlertDialog",
8+
"license": "Apache-2.0",
9+
"repository": {
10+
"type": "git",
11+
"url": "https://github.com/adobe/spectrum-web-components.git",
12+
"directory": "packages/alert-dialog"
13+
},
14+
"author": "",
15+
"homepage": "https://adobe.github.io/spectrum-web-components/components/alert-dialog",
16+
"bugs": {
17+
"url": "https://github.com/adobe/spectrum-web-components/issues"
18+
},
19+
"main": "./src/index.js",
20+
"module": "./src/index.js",
21+
"type": "module",
22+
"exports": {
23+
".": {
24+
"development": "./src/index.dev.js",
25+
"default": "./src/index.js"
26+
},
27+
"./package.json": "./package.json",
28+
"./src/AlertDialog.js": {
29+
"development": "./src/AlertDialog.dev.js",
30+
"default": "./src/AlertDialog.js"
31+
},
32+
"./src/alert-dialog.css.js": "./src/alert-dialog.css.js",
33+
"./src/index.js": {
34+
"development": "./src/index.dev.js",
35+
"default": "./src/index.js"
36+
},
37+
"./sp-alert-dialog.js": {
38+
"development": "./sp-alert-dialog.dev.js",
39+
"default": "./sp-alert-dialog.js"
40+
}
41+
},
42+
"scripts": {
43+
"test": "echo \"Error: run tests from mono-repo root.\" && exit 1"
44+
},
45+
"files": [
46+
"**/*.d.ts",
47+
"**/*.js",
48+
"**/*.js.map",
49+
"custom-elements.json",
50+
"!stories/",
51+
"!test/"
52+
],
53+
"keywords": [
54+
"spectrum css",
55+
"web components",
56+
"lit-element",
57+
"lit-html"
58+
],
59+
"dependencies": {
60+
"@spectrum-web-components/base": "^0.38.0",
61+
"@spectrum-web-components/button": "^0.38.0",
62+
"@spectrum-web-components/button-group": "^0.38.0",
63+
"@spectrum-web-components/divider": "^0.38.0",
64+
"@spectrum-web-components/icons-workflow": "^0.38.0",
65+
"@spectrum-web-components/shared": "^0.38.0"
66+
},
67+
"devDependencies": {
68+
"@spectrum-css/alertdialog": "^1.0.6"
69+
},
70+
"types": "./src/index.d.ts",
71+
"customElements": "custom-elements.json",
72+
"sideEffects": [
73+
"./sp-*.js",
74+
"./**/*.dev.js",
75+
"./**/*.dev.js"
76+
]
77+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
Copyright 2023 Adobe. All rights reserved.
3+
This file is licensed to you under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License. You may obtain a copy
5+
of the License at http://www.apache.org/licenses/LICENSE-2.0
6+
7+
Unless required by applicable law or agreed to in writing, software distributed under
8+
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
9+
OF ANY KIND, either express or implied. See the License for the specific language
10+
governing permissions and limitations under the License.
11+
*/
12+
import { AlertDialog } from './src/AlertDialog.js';
13+
14+
import { defineElement } from '@spectrum-web-components/base/src/define-element.js';
15+
defineElement('sp-alert-dialog', AlertDialog);
16+
17+
declare global {
18+
interface HTMLElementTagNameMap {
19+
'sp-alert-dialog': AlertDialog;
20+
}
21+
}

0 commit comments

Comments
 (0)