@codecademy/styleguide 79.1.4-alpha.feaf95.0 → 79.1.4
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/CHANGELOG.md +1 -1
- package/package.json +2 -2
- package/src/lib/Molecules/Popover/Popover.mdx +0 -6
- package/src/lib/Molecules/Popover/Popover.stories.tsx +2 -39
- package/src/lib/UX Writing/Component guidelines/Confirmation dialogs.mdx +44 -26
- package/src/static/ux writing/clear_chat.png +0 -0
- package/src/static/ux writing/delete_study_plan.png +0 -0
- package/src/static/ux writing/delete_this_course.png +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
-
### [79.1.4
|
|
6
|
+
### [79.1.4](https://github.com/Codecademy/gamut/compare/@codecademy/styleguide@79.1.3...@codecademy/styleguide@79.1.4) (2026-03-09)
|
|
7
7
|
|
|
8
8
|
**Note:** Version bump only for package @codecademy/styleguide
|
|
9
9
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codecademy/styleguide",
|
|
3
3
|
"description": "Styleguide & Component library for codecademy.com",
|
|
4
|
-
"version": "79.1.4
|
|
4
|
+
"version": "79.1.4",
|
|
5
5
|
"author": "Codecademy Engineering",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"publishConfig": {
|
|
8
8
|
"access": "public"
|
|
9
9
|
},
|
|
10
10
|
"repository": "git@github.com:Codecademy/gamut.git",
|
|
11
|
-
"gitHead": "
|
|
11
|
+
"gitHead": "d98acbdeb5f02be1c5b6592f2968300b9c0c19fe"
|
|
12
12
|
}
|
|
@@ -24,12 +24,6 @@ export const parameters = {
|
|
|
24
24
|
|
|
25
25
|
<ComponentHeader {...parameters} />
|
|
26
26
|
|
|
27
|
-
## FOR TESTING/DEMONSTRATION PURPOSES ONLY
|
|
28
|
-
|
|
29
|
-
Verify that the beak renders correctly without the background covering any content
|
|
30
|
-
|
|
31
|
-
<Canvas of={PopoverStories.ClearBeakExample} />
|
|
32
|
-
|
|
33
27
|
## Usage
|
|
34
28
|
|
|
35
29
|
Popovers are generally used for interactive contents, such as new and exciting features for users to try.
|
|
@@ -7,8 +7,6 @@ import {
|
|
|
7
7
|
PopoverProps,
|
|
8
8
|
} from '@codecademy/gamut';
|
|
9
9
|
import * as patterns from '@codecademy/gamut-patterns';
|
|
10
|
-
import { theme } from '@codecademy/gamut-styles';
|
|
11
|
-
import styled from '@emotion/styled';
|
|
12
10
|
import type { Meta, StoryObj } from '@storybook/react';
|
|
13
11
|
import { useRef, useState } from 'react';
|
|
14
12
|
|
|
@@ -33,23 +31,13 @@ const PopoverExample = ({ p = 16, ...rest }: PopoverExampleProps) => {
|
|
|
33
31
|
const [open, setOpen] = useState(false);
|
|
34
32
|
const activeElRef = useRef<HTMLDivElement>(null);
|
|
35
33
|
const toggleOpen = () => setOpen(!open);
|
|
36
|
-
|
|
37
|
-
const PopoverWithClearBeak = styled(Popover)`
|
|
38
|
-
& [data-testid='popover-beak'] {
|
|
39
|
-
background: linear-gradient(
|
|
40
|
-
to top left,
|
|
41
|
-
${theme.colors['background-current']} 50%,
|
|
42
|
-
transparent 50%
|
|
43
|
-
);
|
|
44
|
-
}
|
|
45
|
-
`;
|
|
46
34
|
return (
|
|
47
35
|
<>
|
|
48
36
|
<Box ref={activeElRef} width="fit-content">
|
|
49
37
|
<FillButton onClick={toggleOpen}>Open Popover</FillButton>
|
|
50
38
|
</Box>
|
|
51
39
|
<FlexBox>
|
|
52
|
-
<
|
|
40
|
+
<Popover
|
|
53
41
|
{...(rest as any)}
|
|
54
42
|
isOpen={open}
|
|
55
43
|
targetRef={activeElRef}
|
|
@@ -61,37 +49,12 @@ const PopoverExample = ({ p = 16, ...rest }: PopoverExampleProps) => {
|
|
|
61
49
|
Close Popover
|
|
62
50
|
</FillButton>
|
|
63
51
|
</FlexBox>
|
|
64
|
-
</
|
|
52
|
+
</Popover>
|
|
65
53
|
</FlexBox>
|
|
66
54
|
</>
|
|
67
55
|
);
|
|
68
56
|
};
|
|
69
57
|
|
|
70
|
-
export const ClearBeakExample: Story = {
|
|
71
|
-
render: (args) => (
|
|
72
|
-
<FlexBox gap={16}>
|
|
73
|
-
<PopoverExample {...args} beak="center" p={0} />
|
|
74
|
-
<PopoverExample {...args} beak="center" p={0} position="above" />
|
|
75
|
-
<PopoverExample
|
|
76
|
-
{...args}
|
|
77
|
-
align="right"
|
|
78
|
-
beak="center"
|
|
79
|
-
p={0}
|
|
80
|
-
pattern={undefined}
|
|
81
|
-
position="center"
|
|
82
|
-
/>
|
|
83
|
-
<PopoverExample
|
|
84
|
-
{...args}
|
|
85
|
-
align="left"
|
|
86
|
-
beak="center"
|
|
87
|
-
p={0}
|
|
88
|
-
pattern={undefined}
|
|
89
|
-
position="center"
|
|
90
|
-
/>
|
|
91
|
-
</FlexBox>
|
|
92
|
-
),
|
|
93
|
-
};
|
|
94
|
-
|
|
95
58
|
export const Default: Story = {
|
|
96
59
|
render: (args) => <PopoverExample {...args} />,
|
|
97
60
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Meta } from '@storybook/blocks';
|
|
2
2
|
|
|
3
|
-
import { AboutHeader, LinkTo } from '~styleguide/blocks';
|
|
3
|
+
import { AboutHeader, ImageWrapper, LinkTo } from '~styleguide/blocks';
|
|
4
4
|
|
|
5
5
|
export const parameters = {
|
|
6
6
|
title: 'Confirmation dialogs',
|
|
7
7
|
subtitle:
|
|
8
|
-
'
|
|
8
|
+
'Use the same verb from the triggering button, heading, to action confirmation button; clearly communicate the consequences; and keep the copy decision-focused.',
|
|
9
9
|
status: 'static',
|
|
10
10
|
design: {
|
|
11
11
|
type: 'figma',
|
|
@@ -17,39 +17,57 @@ export const parameters = {
|
|
|
17
17
|
|
|
18
18
|
<AboutHeader {...parameters} />
|
|
19
19
|
|
|
20
|
-
Confirmation
|
|
20
|
+
Confirmation dialogs use the <LinkTo id="Molecules/Modals/Dialog">Dialog component in Gamut</LinkTo> to create intentional friction to verify that a learner wants to take a high-impact action, such as:
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
- Irreversible actions (e.g., submitting payment)
|
|
23
|
+
- Loss of data, time, or work (e.g., deleting a course)
|
|
24
|
+
- Unexpected consequences (e.g., losing learning history on an existing prototype when when generating a new prototype)
|
|
25
|
+
|
|
26
|
+
Adding friction for these purposes helps improve trust and avoid unintentional actions by making sure learners clearly understand the consequences before continuing. It also lets us offer alternatives or undo options when needed.
|
|
23
27
|
|
|
24
28
|
## Best practices
|
|
25
29
|
|
|
26
|
-
###
|
|
30
|
+
### Heading
|
|
31
|
+
|
|
32
|
+
- **Ask or inform about one main action**, mirroring the button that triggered the confirmation dialog.
|
|
33
|
+
- **Frame your headline as a binary question**, when possible, with 2 unambiguous answers.
|
|
34
|
+
- **Avoid generic “Are you sure?” headings and body text.** This phrasing takes up space, increases cognitive load, and may undermine users' confidence or be interpreted as patronizing.
|
|
35
|
+
|
|
36
|
+
### Body (optional)
|
|
37
|
+
|
|
38
|
+
- **Add essential information about the contextual consequences.** State what will happen, what will be lost/changed, and any critical conditions.
|
|
39
|
+
- **Avoid redundancy.** If the heading is already self-explanatory, the body is not needed.
|
|
40
|
+
- **Keep to 1–2 lines, unless more is required to get all the information across.**
|
|
41
|
+
|
|
42
|
+
### Buttons (CTA1 and CTA2)
|
|
27
43
|
|
|
28
|
-
- **
|
|
29
|
-
- **
|
|
30
|
-
- **
|
|
44
|
+
- **Avoid using “Yes” or “No,”** as they can be misinterpreted in global English and internationalization contexts.
|
|
45
|
+
- **CTA1 matches the verb from the heading** to confirm the action.
|
|
46
|
+
- **CTA2 clarifies the alternative or undo** path.
|
|
47
|
+
- Whenever possible, be specific about the alternative. However, when space is limited, 'Cancel' can be used.
|
|
31
48
|
|
|
32
|
-
###
|
|
49
|
+
### Examples — putting it all together
|
|
33
50
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
51
|
+
<ImageWrapper
|
|
52
|
+
src="./ux writing/delete_this_course.png"
|
|
53
|
+
alt="Delete this course confirmation dialog"
|
|
54
|
+
/>
|
|
38
55
|
|
|
39
|
-
|
|
56
|
+
<ImageWrapper
|
|
57
|
+
src="./ux writing/delete_study_plan.png"
|
|
58
|
+
alt="Delete study plan confirmation dialog"
|
|
59
|
+
/>
|
|
40
60
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
61
|
+
<ImageWrapper
|
|
62
|
+
src="./ux writing/clear_chat.png"
|
|
63
|
+
alt="Clear chat confirmation dialog"
|
|
64
|
+
/>
|
|
44
65
|
|
|
45
66
|
## Checklist
|
|
46
67
|
|
|
47
|
-
- Is the
|
|
48
|
-
-
|
|
49
|
-
-
|
|
50
|
-
- Does the
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
- Do the buttons include context to reaffirm the action?
|
|
54
|
-
- Is your copy at a reading level of grade 7 or below? Test with [Hemingway App](https://hemingwayapp.com).
|
|
55
|
-
- Have you asked someone unrelated to the project to read the message and did they understand it?
|
|
68
|
+
- Is the action irreversible, destructive, or has unexpected consequences? If not, consider using a different pattern.
|
|
69
|
+
- Is the same verb used from the action triggering the confirmation dialog, to the heading, to CTA1?
|
|
70
|
+
- Did you avoid filler language such as “Are you sure you want to...?”
|
|
71
|
+
- Does the body front-load the critical consequence in 1–3 lines?
|
|
72
|
+
- Are the buttons mutually exclusive (and avoid using “Yes/No”)?
|
|
73
|
+
- Is there a safer alternative or undo to mention? (If available, offer the option as CTA2.)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|