Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Design/error alert #1937

Merged
merged 8 commits into from
Jul 19, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -81,6 +81,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"
}
}
}
}