Skip to content

Commit

Permalink
Alert component A11Y changes (#678)
Browse files Browse the repository at this point in the history
* feat: Add dev mode toggle for css framework

* feat: add new alert design to meet WCAG Guidelines
  • Loading branch information
hxltrhuxze authored Mar 3, 2020
1 parent b6e7aed commit a0560f8
Show file tree
Hide file tree
Showing 9 changed files with 177 additions and 165 deletions.
1 change: 1 addition & 0 deletions packages/css-framework/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
@use "src/base/normalize";
@use "src/base/box-sizing";
@use "src/base/fonts";
@use "src/base/dev";


// Components
Expand Down
3 changes: 3 additions & 0 deletions packages/css-framework/src/_config.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ $utility-ns: "rn_";

$content-width: 1280px;
$animation-timing: 0.3s;

// Dev helpers
$dev-mode: false !default;
8 changes: 8 additions & 0 deletions packages/css-framework/src/base/_dev.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
@use "../config";

@if config.$dev-mode == true {
// Adds padding to the storybook wrapper
.sb-show-main {
padding: 40px;
}
}
10 changes: 9 additions & 1 deletion packages/css-framework/src/base/_fonts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,43 @@ html {

h1,
.rn-h1 {
margin: 0;
@include font-size("xxl");
}

h2,
.rn-h2 {
margin: 0;
@include font-size("xl");
}

h3,
.rn-h3 {
margin: 0;
@include font-size("l");
}

h4,
.rn-h4 {
margin: 0;
@include font-size("m");
}

h5,
.rn-h5 {
margin: 0;
@include font-size("base");
}

h6,
.rn-h6 {
margin: 0;
@include font-size("s");
}

p,
.rn-p {
@include font-size("base");
margin: 0;
@include font-size("base");
line-height: 1.5;
}
201 changes: 109 additions & 92 deletions packages/css-framework/src/components/_alert.scss
Original file line number Diff line number Diff line change
@@ -1,144 +1,161 @@
@use "../abstracts/mixins" as m;
@use "../abstracts/functions" as f;

$_alert-background-colour: f.color("action", "000");
$_alert-border-colour: f.color("action", "500");
$_alert-title-colour: f.color("action", "800");
$_alert-close-colour: f.color("action", "500");
$_alert-description-colour: f.color("action", "700");
$_alert-background-color: f.color("neutral", "white");
$_alert-border-color: f.color("neutral", "100");
$_alert-state-color: f.color("action", "500");
$_alert-title-color: f.color("neutral", "600");
$_alert-icon-color: f.color("action", "500");
$_alert-close-color: f.color("neutral", "300");
$_alert-close-color--hover: f.color("neutral", "500");
$_alert-close-background-color: f.color("neutral", "white");
$_alert-close-background-color--hover: f.color("neutral", "000");
$_alert-description-color: f.color("neutral", "400");
$_alert-footer-border-color: f.color("neutral", "000");

// Danger
$_danger-alert-background-colour: f.color("danger", "000");
$_danger-alert-border-colour: f.color("danger", "500");
$_danger-alert-title-colour: f.color("danger", "800");
$_danger-alert-close-colour: f.color("danger", "500");
$_danger-alert-description-colour: f.color("danger", "700");
$_danger-alert-background-color: f.color("danger", "000");
$_danger-alert-state-color: f.color("danger", "500");
$_danger-alert-title-color: f.color("danger", "800");
$_danger-alert-icon-color: f.color("danger", "500");


// Success
$_success-alert-background-colour: f.color("success", "000");
$_success-alert-border-colour: f.color("success", "500");
$_success-alert-title-colour: f.color("success", "900");
$_success-alert-close-colour: f.color("success", "500");
$_success-alert-description-colour: f.color("success", "800");
$_success-alert-background-color: f.color("success", "000");
$_success-alert-state-color: f.color("success", "500");
$_success-alert-title-color: f.color("success", "900");
$_success-alert-icon-color: f.color("success", "600");


// Warning
$_warning-alert-background-colour: f.color("warning", "000");
$_warning-alert-border-colour: f.color("warning", "500");
$_warning-alert-title-colour: f.color("warning", "900");
$_warning-alert-close-colour: f.color("warning", "500");
$_warning-alert-description-colour: f.color("warning", "800");
$_warning-alert-background-color: f.color("warning", "000");
$_warning-alert-state-color: f.color("warning", "500");
$_warning-alert-title-color: f.color("warning", "900");
$_warning-alert-icon-color: f.color("warning", "600");

.rn-alert {
background-color: $_alert-background-colour;
border-radius: 0px 4px 4px 0px;
border-left: 4px solid $_alert-border-colour;
padding: 16px;
background-color: $_alert-background-color;
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
border: f.spacing("px") solid $_alert-border-color;
border-radius: 4px;
padding: f.spacing("4") f.spacing("4") f.spacing("4") f.spacing("6");
position: relative;
display: flex;
align-items: flex-start;

&--danger {
background-color: $_danger-alert-background-colour;
border-left-color: $_danger-alert-border-colour;
@include m.breakpoint("s") {
padding-right: f.spacing("18");
}

&--success {
background-color: $_success-alert-background-colour;
border-left-color: $_success-alert-border-colour;
&::before {
position: absolute;
top: 8px;
left: 8px;
bottom: 8px;
content: "";
width: 4px;
background: $_alert-state-color;
border-radius: 4px;
}

&--warning {
background-color: $_warning-alert-background-colour;
border-left-color: $_warning-alert-border-colour;
}
}

.rn-alert__header {
display: flex;
margin-bottom: f.spacing("1");
}

.rn-alert__icon {
display: inline-flex;
align-items: center;
color: $_alert-title-colour;
padding-right: f.spacing("3");

&--danger {
color: $_danger-alert-title-colour;
&--danger::before {
background-color: $_danger-alert-state-color;
}

&--success {
color: $_success-alert-title-colour;
&--success::before {
background-color: $_success-alert-state-color;
}

&--warning {
color: $_warning-alert-title-colour;
&--warning::before {
background-color: $_warning-alert-state-color;
}
}

.rn-alert__title {
color: $_alert-title-colour;
font-size: f.font-size("m");
font-weight: bold;

&--danger {
color: $_danger-alert-title-colour;
.rn-alert__close {
margin-left: auto;
border: none;
font-size: f.font-size("base");
color: $_alert-close-color;
font-weight: 600;
transition: all 0.3s;
border-radius: 2px;
padding: f.spacing("4") f.spacing("10");
background-color: $_alert-close-background-color--hover;
@include m.breakpoint("s") {
position: absolute;
background-color: $_alert-close-background-color;
margin-top: 0;
top: f.spacing("4");
right: f.spacing("4");
bottom: f.spacing("4");
padding: f.spacing("2");
width: f.spacing("17");
}

&--success {
color: $_success-alert-title-colour;
&:hover {
background-color: $_alert-close-background-color--hover;
color: $_alert-close-color--hover;
cursor: pointer;
}
}

&--warning {
color: $_warning-alert-title-colour;
}
.rn-alert__content {
width: 100%;
padding: f.spacing("4") f.spacing("4") f.spacing("4") 0;
}

.rn-alert__close {
position: absolute;
top: f.spacing("1");
right: f.spacing("1");
border: none;
font-size: f.font-size("xl");
color: $_alert-close-colour;
background-color: $_alert-background-colour;
.rn-alert__description {
color: $_alert-description-color;
font-size: f.font-size("base");
font-weight: 400;
}

&:hover {
cursor: pointer;
.rn-alert__footer {
border-top: f.spacing("px") solid $_alert-footer-border-color;
padding-top: f.spacing("6");
margin-top: f.spacing("6");
@include m.breakpoint("s") {
border-top: none;
padding-top: 0;
margin-top: 0;
}
}

.rn-alert__icon {
display: inline-flex;
align-self: flex-start;
color: $_alert-icon-color;
padding: f.spacing("4") f.spacing("5") f.spacing("4") f.spacing("6");
transform: translateY(1px);

&--danger {
color: $_danger-alert-close-colour;
background-color: $_danger-alert-background-colour;
color: $_danger-alert-icon-color;
}

&--success {
color: $_success-alert-close-colour;
background-color: $_success-alert-background-colour;
color: $_success-alert-icon-color;
}

&--warning {
color: $_warning-alert-close-colour;
background-color: $_warning-alert-background-colour;
color: $_warning-alert-icon-color;
}
}

.rn-alert__content {
display: inline-flex;
align-items: center;
}

.rn-alert__description {
color: $_alert-description-colour;
font-size: f.font-size("base");
.rn-alert__title {
color: $_alert-title-color;
font-size: f.font-size("l");
font-weight: bold;
margin-bottom: f.spacing("2");

&--danger {
color: $_danger-alert-description-colour;
color: $_danger-alert-title-color;
}

&--success {
color: $_success-alert-description-colour;
color: $_success-alert-title-color;
}

&--warning {
color: $_warning-alert-description-colour;
color: $_warning-alert-title-color;
}
}
20 changes: 10 additions & 10 deletions packages/css-framework/src/contexts/_light.scss
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,16 @@
"000": #fff8f3,
),
"warning": (
"900": #804701,
"800": #9f5a06,
"700": #c3771a,
"600": #e8a224,
"500": #fab73d,
"400": #ffd062,
"300": #ffdf80,
"200": #feedb8,
"100": #fff6dc,
"000": #fffcee,
"900": #693a12,
"800": #8c4f17,
"700": #ae6d1d,
"600": #cf9328,
"500": #e8c242,
"400": #f5db54,
"300": #faed7e,
"200": #fefbb8,
"100": #fffddc,
"000": #ffffee,
),
"success": (
"900": #3b612c,
Expand Down
Loading

0 comments on commit a0560f8

Please sign in to comment.