Skip to content

Commit 00ef68d

Browse files
committed
chore(alert dialog): cleanup for stories, templates and styles
1 parent 30c40a0 commit 00ef68d

File tree

8 files changed

+39
-31
lines changed

8 files changed

+39
-31
lines changed

.changeset/lemon-flowers-poke.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ The dialog divider has been removed.
1212

1313
Primary button style has been updated to filled.
1414

15-
Multiple variants are now supported:
15+
The following variants remain supported:
1616

1717
- Confirmation
1818
- Information
@@ -24,7 +24,6 @@ Dialog buttons may be displayed either horizontally or vertically.
2424

2525
##### Removed custom properties
2626

27-
`--spectrum-alert-dialog-body-font-size`
2827
`--spectrum-alert-dialog-description-to-buttons`
2928
`--spectrum-alert-dialog-divider-to-description`
3029
`--spectrum-alert-dialog-padding`
@@ -36,9 +35,10 @@ Dialog buttons may be displayed either horizontally or vertically.
3635

3736
`--spectrum-alert-dialog-background-color`
3837
`--spectrum-alert-dialog-corner-radius`
38+
`--spectrum-alert-dialog-description-font-size`
3939
`--spectrum-alert-dialog-description-to-button-group`
4040
`--spectrum-alert-dialog-edge-to-content`
41-
`--spectrum-alert-dialog-minimum-title-to-icon`
41+
`--spectrum-alert-dialog-heading-size`
4242
`--spectrum-alert-dialog-title-to-description`
4343

4444
##### Removed mods
@@ -57,5 +57,6 @@ Dialog buttons may be displayed either horizontally or vertically.
5757
`--mod-alert-dialog-description-size`
5858
`--mod-alert-dialog-description-to-button-group`
5959
`--mod-alert-dialog-edge-to-content`
60+
`--mod-alert-dialog-heading-size`
6061
`--mod-alert-dialog-minimum-title-to-icon`
6162
`--mod-alert-dialog-title-to-description`

components/alertdialog/dist/metadata.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
"--mod-alert-dialog-description-to-button-group",
2424
"--mod-alert-dialog-edge-to-content",
2525
"--mod-alert-dialog-error-icon-color",
26+
"--mod-alert-dialog-heading-size",
2627
"--mod-alert-dialog-icon-size",
2728
"--mod-alert-dialog-max-width",
2829
"--mod-alert-dialog-min-width",
2930
"--mod-alert-dialog-minimum-title-to-icon",
3031
"--mod-alert-dialog-title-color",
3132
"--mod-alert-dialog-title-font-family",
32-
"--mod-alert-dialog-title-font-size",
3333
"--mod-alert-dialog-title-font-style",
3434
"--mod-alert-dialog-title-font-weight",
3535
"--mod-alert-dialog-title-line-height",
@@ -44,10 +44,12 @@
4444
"--spectrum-alert-dialog-body-font-weight",
4545
"--spectrum-alert-dialog-body-line-height",
4646
"--spectrum-alert-dialog-corner-radius",
47+
"--spectrum-alert-dialog-description-font-size",
4748
"--spectrum-alert-dialog-description-size",
4849
"--spectrum-alert-dialog-description-to-button-group",
4950
"--spectrum-alert-dialog-edge-to-content",
5051
"--spectrum-alert-dialog-error-icon-color",
52+
"--spectrum-alert-dialog-heading-size",
5153
"--spectrum-alert-dialog-icon-size",
5254
"--spectrum-alert-dialog-max-width",
5355
"--spectrum-alert-dialog-maximum-width",

components/alertdialog/index.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
--spectrum-alert-dialog-title-font-style: var(--spectrum-heading-sans-serif-font-style);
2929
--spectrum-alert-dialog-title-line-height: var(--spectrum-heading-line-height);
3030
--spectrum-alert-dialog-title-color: var(--spectrum-heading-color);
31+
--spectrum-alert-dialog-heading-size: var(--spectrum-alert-dialog-title-font-size);
32+
--spectrum-alert-dialog-description-size: var(--spectrum-alert-dialog-description-font-size);
3133

3234
--spectrum-alert-dialog-body-font-family: var(--spectrum-sans-font-family-stack);
3335
--spectrum-alert-dialog-body-font-weight: var(--spectrum-body-sans-serif-font-weight);
@@ -89,7 +91,7 @@
8991
font-family: var(--mod-alert-dialog-title-font-family, var(--spectrum-alert-dialog-title-font-family));
9092
font-weight: var(--mod-alert-dialog-title-font-weight, var(--spectrum-alert-dialog-title-font-weight));
9193
font-style: var(--mod-alert-dialog-title-font-style, var(--spectrum-alert-dialog-title-font-style));
92-
font-size: var(--mod-alert-dialog-title-font-size, var(--spectrum-alert-dialog-title-font-size));
94+
font-size: var(--mod-alert-dialog-heading-size, var(--spectrum-alert-dialog-heading-size));
9395
line-height: var(--mod-alert-dialog-title-line-height, var(--spectrum-alert-dialog-title-line-height));
9496
color: var(--mod-alert-dialog-title-color, var(--spectrum-alert-dialog-title-color));
9597
margin: 0;
@@ -99,8 +101,6 @@
99101
font-family: var(--mod-alert-dialog-body-font-family, var(--spectrum-alert-dialog-body-font-family));
100102
font-weight: var(--mod-alert-dialog-body-font-weight, var(--spectrum-alert-dialog-body-font-weight));
101103
font-style: var(--mod-alert-dialog-body-font-style, var(--spectrum-alert-dialog-body-font-style));
102-
103-
/* @TODO: update to `--spectrum-alert-dialog-body-font-size` when available */
104104
font-size: var(--mod-alert-dialog-description-size, var(--spectrum-alert-dialog-description-size));
105105
line-height: var(--mod-alert-dialog-body-line-height, var(--spectrum-alert-dialog-body-line-height));
106106
color: var(--mod-alert-dialog-body-color, var(--spectrum-alert-dialog-body-color));

components/alertdialog/stories/alertdialog.stories.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ export default {
4242
options: ["confirmation", "information", "destructive", "warning", "error"],
4343
control: "select",
4444
},
45-
buttonsAreVertical: {
45+
hasVerticalButtons: {
4646
name: "Vertical buttons",
47-
description: "Buttons can be displayed horizontally (default) or vertically.",
47+
description: "In limited horizontal space, the button group may stack vertically.",
4848
type: { name: "boolean" },
4949
table: {
5050
type: { summary: "boolean" },
@@ -56,7 +56,7 @@ export default {
5656
args: {
5757
rootClass: "spectrum-AlertDialog",
5858
isOpen: true,
59-
buttonsAreVertical: false,
59+
hasVerticalButtons: false,
6060
variant: "confirmation",
6161
},
6262
parameters: {
@@ -86,6 +86,7 @@ export default {
8686
};
8787

8888
export const Default = AlertDialogGroup.bind({});
89+
Default.storyName = "Default (confirmation)";
8990
Default.args = {
9091
isOpen: true,
9192
heading: "Enable smart filters?",
@@ -152,7 +153,7 @@ Error.args = {
152153
variant: "error",
153154
heading: "Unable to share",
154155
icon: "Alert",
155-
content: "An error occured while sharing your project. Please verify the email address and try again.",
156+
content: "An error occurred while sharing your project. Please verify the email address and try again.",
156157
};
157158
Error.parameters = {
158159
chromatic: { disableSnapshot: true },
@@ -212,12 +213,13 @@ Scroll.parameters = {
212213
};
213214

214215
/**
215-
* When horizontal space is limited, button groups stack vertically. They should appear in ascending order based on importance, with the most critical action at the bottom.
216+
* Buttons are stacked by the importance of the action, with the most critical or primary action at the bottom.
216217
*/
217218
export const VerticalButtons = Template.bind({});
219+
VerticalButtons.storyName = "Vertical buttons";
218220
VerticalButtons.tags = ["!dev"];
219221
VerticalButtons.args = {
220-
buttonsAreVertical: true,
222+
hasVerticalButtons: true,
221223
isOpen: true,
222224
heading: "Vertical button group",
223225
content: "This is what an alert dialog looks like with buttons arranged vertically.",

components/alertdialog/stories/alertdialog.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,29 @@ export const AlertDialogGroup = Variants({
1212
"min-block-size": "auto",
1313
},
1414
testData: [{}, {
15+
testHeading: "Vertical button display",
1516
heading: "Vertical button group",
1617
content: "This is what an alert dialog looks like with buttons arranged vertically.",
17-
buttonsAreVertical: true,
18+
hasVerticalButtons: true,
1819
}, {
20+
testHeading: "Warning",
1921
variant: "warning",
2022
heading: "Unverified format",
2123
content: "This format has not been verified and may not be viewable for some users. Do you want to continue publishing?",
2224
}, {
25+
testHeading: "Error",
2326
variant: "error",
2427
heading: "Unable to share",
2528
content: "An error occured while sharing your project. Please verify the email address and try again.",
2629
}, {
30+
testHeading: "Destructive",
2731
variant: "destructive",
2832
heading: "Delete 3 documents?",
2933
content: "Are you sure you want to delete the 3 selected documents?",
3034
}, {
35+
testHeading: "Informative",
3136
variant: "information",
32-
heading: "Informative Dialog with a wrapping title text because the text is longer than the width of the alert dialog",
37+
heading: "Informative dialog with a wrapping title text because the text is longer than the width of the alert dialog",
3338
content: "If you enjoy our app, would you mind taking a moment to rate it?",
3439
}],
3540
});

components/alertdialog/stories/template.js

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ const buttonMap = {
2121
treatment: "outline",
2222
label: "Remind me later"
2323
}, {
24+
variant: "accent",
2425
treatment: "fill",
25-
label: "Enable",
26-
variant: "accent"
26+
label: "Enable"
2727
}],
2828
information: [{
2929
variant: "secondary",
@@ -35,35 +35,35 @@ const buttonMap = {
3535
label: "Remind me later"
3636
}, {
3737
variant: "primary",
38-
treatment: "outline",
39-
label: "Rate now",
38+
treatment: "fill",
39+
label: "Rate now"
4040
}],
4141
destructive: [{
4242
variant: "secondary",
4343
treatment: "outline",
4444
label: "Cancel"
4545
}, {
46+
variant: "negative",
4647
treatment: "fill",
47-
label: "Delete",
48-
variant: "negative"
48+
label: "Delete"
4949
}],
5050
warning: [{
5151
variant: "secondary",
5252
treatment: "outline",
5353
label: "Cancel"
5454
}, {
55+
variant: "primary",
5556
treatment: "fill",
56-
label: "Continue",
57-
variant: "primary"
57+
label: "Continue"
5858
}],
5959
error: [{
6060
variant: "secondary",
6161
treatment: "outline",
6262
label: "Cancel"
6363
}, {
64+
variant: "primary",
6465
treatment: "fill",
65-
label: "Continue",
66-
variant: "primary"
66+
label: "Continue"
6767
}],
6868
};
6969

@@ -73,7 +73,7 @@ export const Dialog = ({
7373
content,
7474
customClasses = [],
7575
variant,
76-
buttonsAreVertical,
76+
hasVerticalButtons,
7777
id = getRandomId("alertdialog"),
7878
customStyles = {},
7979
} = {}, context = {}) => {
@@ -103,7 +103,7 @@ export const Dialog = ({
103103
</div>
104104
<section class="${rootClass}-content">${content}</section>
105105
<section class="${rootClass}-buttongroup">
106-
${ButtonGroup({ items: buttonMap[variant], vertical: buttonsAreVertical }, context)}
106+
${ButtonGroup({ items: buttonMap[variant], vertical: hasVerticalButtons }, context)}
107107
</section>
108108
</div>
109109
</div>
@@ -112,7 +112,6 @@ export const Dialog = ({
112112

113113
export const Template = ({
114114
isOpen = true,
115-
customModalStyles = {},
116115
skipWrapper = false,
117116
...args
118117
} = {}, context = {}) => {
@@ -121,7 +120,6 @@ export const Template = ({
121120
content: [
122121
Dialog(args, context)
123122
],
124-
customStyles: customModalStyles,
125123
skipWrapper,
126124
}, context);
127125
};

tokens/custom/large-vars.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
--spectrum-alert-banner-edge-to-button: var(--spectrum-spacing-200);
2323
--spectrum-alert-banner-text-to-button-vertical: var(--spectrum-spacing-200);
2424

25-
--spectrum-alert-dialog-edge-to-content: var(--spectrum-spacing-500);
25+
--spectrum-alert-dialog-edge-to-content: var(--spectrum-spacing-400);
2626

2727
--spectrum-assetcard-focus-ring-border-radius: 9px;
2828
--spectrum-assetcard-selectionindicator-margin: 15px;

tokens/custom/medium-vars.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
--spectrum-alert-banner-edge-to-divider: var(--spectrum-spacing-100);
2323
--spectrum-alert-banner-text-to-button-vertical: var(--spectrum-spacing-100);
2424

25-
--spectrum-alert-dialog-edge-to-content: var(--spectrum-spacing-400);
25+
--spectrum-alert-dialog-edge-to-content: var(--spectrum-spacing-500);
2626

2727
--spectrum-assetcard-content-font-size: var(--spectrum-body-size-s);
2828
--spectrum-assetcard-focus-ring-border-radius: 8px;

0 commit comments

Comments
 (0)