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 3 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 alert, confused face icon, and Status color design tokens.
AriannaChau marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 6 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.
11 changes: 11 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 @@ -149,3 +153,10 @@
transform: scale(scale.$effect-shrink);
}
}

.c-alert__error {
AriannaChau marked this conversation as resolved.
Show resolved Hide resolved
.c-alert__extra {
background-color: var(--theme-color-background-icon-error);
color: var(--theme-color-icon-error);
}
}
AriannaChau marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 18 additions & 0 deletions src/components/alert/alert.stories.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,24 @@ Alerts work well even when displayed at full width. Their contents will constrai
</Story>
</Canvas>

## Error
AriannaChau marked this conversation as resolved.
Show resolved Hide resolved

The 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>

## Icon

An option to add an icon to the alert. You can add any icon name from our library in the `icon` property. Right now, the color is hardcoded to orange to satisfy the current use case of our offline notification, but it would be nice to add more color options in the future.
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

Includes colors that can reflect the status of elements.
AriannaChau marked this conversation as resolved.
Show resolved Hide resolved

<ColorPalette>
<ColorItem
title="$status-error-dark"
colors={[colors.status.error_dark.value]}
/>
<ColorItem
title="$status-error-light"
colors={[colors.status.error_light.value]}
/>
</ColorPalette>
14 changes: 14 additions & 0 deletions src/tokens/color/status.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"color": {
"status": {
"error_dark": {
"value": "#bc1919",
"comment": "For errors, intended to be used for the foreground when used on the light theme"
AriannaChau marked this conversation as resolved.
Show resolved Hide resolved
},
"error_light": {
"value": "#ffcaca",
"comment": "For errors, intended for backgrounds when used on the light theme"
}
}
}
}