Skip to content

Commit

Permalink
Design/error alert (#1937)
Browse files Browse the repository at this point in the history
* Add error alert and status color section

* Add changeset

* Change SVG, documentation and add CSS custom properties

* Update src/design/colors.stories.mdx

Co-authored-by: Tyler Sticka <[email protected]>

* Change size of icon
Edit changeset message
Move content around
Delete comments in json file

* Add clearer description

* Nest c-alert--error class within c-alert__extra class.

Co-authored-by: Tyler Sticka <[email protected]>
  • Loading branch information
AriannaChau and tylersticka authored Jul 19, 2022
1 parent 3da5b7f commit 87f012d
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-glasses-sparkle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@cloudfour/patterns': minor
---

Add new error modifier for the Alert component, confused face icon, and status color design tokens.
5 changes: 5 additions & 0 deletions src/assets/icons/confused-face.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions src/components/alert/alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,15 @@
$lightness: 30%
)};
--theme-color-icon: #{color.$base-orange};
--theme-color-icon-error: #{color.$status-error-dark};
--theme-color-background-icon-error: #{color.$status-error-light};
}

@include theme.props(dark) {
--theme-color-background-icon: #{color.$base-orange};
--theme-color-icon: #{sass-color.adjust(color.$base-orange, $lightness: 30%)};
--theme-color-icon-error: #{color.$status-error-light};
--theme-color-background-icon-error: #{color.$status-error-dark};
}

.c-alert {
Expand Down Expand Up @@ -106,6 +110,11 @@
border: ms.step(-4) solid var(--theme-color-background-secondary);
border-radius: size.$border-radius-full;
}

.c-alert--error & {
background-color: var(--theme-color-background-icon-error);
color: var(--theme-color-icon-error);
}
}

.c-alert__content {
Expand Down
18 changes: 18 additions & 0 deletions src/components/alert/alert.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,24 @@ An option to add an icon to the alert. You can add any icon name from our librar
</Story>
</Canvas>

## Error

The modifier class `c-alert--error` will override the orange default color and make the icon and background red.

<Canvas>
<Story
name="Error"
args={{
message: 'Oops! Something went wrong.',
dismissable: true,
class: 'c-alert--error',
icon: 'confused-face',
}}
>
{(args) => template(args)}
</Story>
</Canvas>

## Floating

By adding `floating: true`, a light border and shadow will be added to the alert for a floating effect. The background is white to improve the contrast between the border, shadow and background. In the future, we could make it a possibility to change the background color by itself.
Expand Down
15 changes: 15 additions & 0 deletions src/design/colors.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,18 @@ We design and build with accessibility in mind. Color contrast for text should m
colors={[colors.text.action.value]}
/>
</ColorPalette>

## Status Colors

These colors help communicate the status of elements, for example an icon accompanying an error message.

<ColorPalette>
<ColorItem
title="$status-error-dark"
colors={[colors.status.error_dark.value]}
/>
<ColorItem
title="$status-error-light"
colors={[colors.status.error_light.value]}
/>
</ColorPalette>
12 changes: 12 additions & 0 deletions src/tokens/color/status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"color": {
"status": {
"error_dark": {
"value": "#bc1919"
},
"error_light": {
"value": "#ffcaca"
}
}
}
}

0 comments on commit 87f012d

Please sign in to comment.