Skip to content

Commit 5ea53a5

Browse files
committed
Add success
1 parent bb8c36b commit 5ea53a5

File tree

3 files changed

+29
-4
lines changed

3 files changed

+29
-4
lines changed

docs/contributing/pages/components.mdx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ This is an info alert. Use these for information that's critical to know; it's i
1616
This is a warning alert. Use these for items that MUST be well understood before proceeding. These highlight information that could cause users to make catastrophic errors that break their applications in ways that are very difficult to fix or create liabilities for them, such as information needed to avoid leaking PII. These should be used very rarely.
1717
</Alert>
1818

19+
<Alert level="success" title="Tip">
20+
This is a success alert. Use these when.... TODO?
21+
</Alert>
22+
1923
<Alert>
2024
This is an alert without title.
2125
</Alert>
@@ -44,6 +48,12 @@ This is a warning alert.
4448
</Alert>
4549
```
4650

51+
```markdown {tabTitle:Success}
52+
<Alert level="success" title="Tip">
53+
This is a success alert.
54+
</Alert>
55+
```
56+
4757
```markdown {tabTitle:No Title}
4858
<Alert>
4959
This is an alert without title.
@@ -53,7 +63,7 @@ This is an alert without title.
5363
Attributes:
5464

5565
- `title` (string) - optional
56-
- `level` (string: `'info' | 'warning') - optional, defaults to `'info'`
66+
- `level` (string: `'info' | 'warning' | 'success') - optional, defaults to `'info'`
5767

5868
Use this for these types of content:
5969

src/components/alert/index.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,28 @@
11
import {ReactNode} from 'react';
2-
import {ExclamationTriangleIcon, InfoCircledIcon} from '@radix-ui/react-icons';
2+
import {
3+
CheckCircledIcon,
4+
ExclamationTriangleIcon,
5+
InfoCircledIcon,
6+
} from '@radix-ui/react-icons';
37

48
// explicitly not usig CSS modules here
59
// because there's some prerendered content that depends on these exact class names
610
import './styles.scss';
711

812
type AlertProps = {
913
children?: ReactNode;
10-
level?: 'info' | 'warning';
14+
level?: 'info' | 'warning' | 'success';
1115
title?: string;
1216
};
1317

18+
const ICON_MAP = {
19+
info: InfoCircledIcon,
20+
warning: ExclamationTriangleIcon,
21+
success: CheckCircledIcon,
22+
} as const;
23+
1424
export function Alert({title, children, level = 'info'}: AlertProps) {
15-
const Icon = level === 'warning' ? ExclamationTriangleIcon : InfoCircledIcon;
25+
const Icon = ICON_MAP[level];
1626

1727
return (
1828
<div className={`alert ${'alert-' + level}`} role="alert">

src/components/alert/styles.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@
4444
background: color-mix(in srgb, var(--desatPurple15), transparent 10%);
4545
}
4646

47+
.alert-success {
48+
background: var(--successGreen);
49+
background: color-mix(in srgb, var(--successGreen), transparent 85%);
50+
}
51+
4752
.alert-warning {
4853
background: var(--desatFlame8);
4954
background: color-mix(in srgb, var(--desatFlame8), transparent 10%);

0 commit comments

Comments
 (0)