Skip to content

Commit e42adee

Browse files
committed
Added Molecules / ErrorBanner
1 parent 37967c1 commit e42adee

8 files changed

Lines changed: 169 additions & 0 deletions

File tree

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
/*------------------------------------*\
22
MOLECULES
33
\*------------------------------------*/
4+
@import "card";
5+
@import "dropdown-button";
6+
@import "error-banner";
47
@import "form-fields";
58
@import "forms";
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
.c-card {
2+
position: relative;
3+
box-shadow: 0px 3px 10px rgba(0, 26, 57, 0.2);
4+
5+
&__content {
6+
background-color: #425163;
7+
height: 147px;
8+
border-radius: 5px 5px 0 0;
9+
@include padding(16px);
10+
position: relative;
11+
12+
p {
13+
@include font-style($font-primary, "base", white, 400, 24px);
14+
position: absolute;
15+
bottom: 16px;
16+
display: -webkit-box;
17+
-webkit-line-clamp: 3;
18+
-webkit-box-orient: vertical;
19+
overflow: hidden;
20+
}
21+
}
22+
23+
&__label {
24+
background: white;
25+
bottom: 0;
26+
width: 100%;
27+
border-radius: 0 0 5px 5px;
28+
border: 1px solid #8d98a5;
29+
30+
p {
31+
@include font-style(
32+
$font-primary,
33+
"small",
34+
get-color("neutral", "dark-text")
35+
);
36+
@include padding(0, 16px);
37+
@include margin(0);
38+
letter-spacing: 0.02em;
39+
font-style: italic;
40+
}
41+
}
42+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
.c-dropdown-button {
2+
svg {
3+
vertical-align: middle;
4+
}
5+
6+
&__list {
7+
@include box-shadow(0, 7px, 20px, rgba(0, 26, 57, 0.3));
8+
@include margin-top(8px);
9+
@include margin-left(64px);
10+
@include font-style($size: "small");
11+
background-color: get-color-neutral("white");
12+
border-radius: $border-radius-small;
13+
14+
&__item {
15+
@include padding(12px);
16+
min-width: rem(162px);
17+
cursor: pointer;
18+
19+
&:hover,
20+
&:focus,
21+
&:focus-within,
22+
&[data-selected] {
23+
// [data-selected] comes from the @reach-ui/menu-button component
24+
background-color: get-color-neutral("05");
25+
}
26+
}
27+
}
28+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
.c-error-banner {
2+
@include padding(8px, 24px, 8px, 32px);
3+
@include font-style(
4+
$font-primary,
5+
"xsmall",
6+
false,
7+
400,
8+
get-line-height("xsmall")
9+
);
10+
color: get-color-status("error-dark");
11+
background-color: get-color-status("error-light");
12+
border-radius: $border-radius-small;
13+
position: relative;
14+
15+
svg {
16+
position: absolute;
17+
left: rem(8px);
18+
top: rem(10px);
19+
path {
20+
fill: get-color-primary("error");
21+
}
22+
}
23+
}

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ export * from "./atoms/interfaces/svg-icon";
6060

6161
export { AccessibleList } from "./molecules/accessible-list/accessible-list";
6262
export { Card } from "./molecules/cards/card";
63+
export { DropdownButton } from "./molecules/dropdown-button/dropdown-button";
64+
export { ErrorBanner } from "./molecules/errors/error-banner";
6365

6466
// #endregion Molecules
6567

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import React from "react";
2+
import { text } from "@storybook/addon-knobs";
3+
import { ErrorBanner } from "./error-banner";
4+
5+
export default {
6+
component: ErrorBanner,
7+
title: "Molecules | Errors / Error Banner",
8+
};
9+
10+
export const errorBannerDefault = () => (
11+
<ErrorBanner text={text("Text", "This is an error message.")} />
12+
);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react";
2+
import { render } from "@testing-library/react";
3+
import { ErrorBanner } from "./error-banner";
4+
import faker from "faker";
5+
6+
describe("ErrorBanner", () => {
7+
test("when default props, renders banner", () => {
8+
// Arrange
9+
const expected = faker.random.words();
10+
11+
// Act
12+
const { getByText } = render(<ErrorBanner text={expected} />);
13+
14+
// Assert
15+
expect(getByText(expected)).not.toBeNull();
16+
});
17+
});
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import React from "react";
2+
import { Icon } from "../../atoms/icons/icon";
3+
import { Icons } from "../../atoms/constants/icons";
4+
5+
// -----------------------------------------------------------------------------------------
6+
// #region Constants
7+
// -----------------------------------------------------------------------------------------
8+
9+
const COMPONENT_CLASS = "c-error-banner";
10+
11+
// #endregion Constants
12+
13+
// -----------------------------------------------------------------------------------------
14+
// #region Interfaces
15+
// -----------------------------------------------------------------------------------------
16+
17+
interface ErrorBannerProps {
18+
text: string;
19+
}
20+
21+
// #endregion Interfaces
22+
23+
// -----------------------------------------------------------------------------------------
24+
// #region Component
25+
// -----------------------------------------------------------------------------------------
26+
27+
const ErrorBanner: React.FC<ErrorBannerProps> = (props: ErrorBannerProps) => (
28+
<div className={COMPONENT_CLASS}>
29+
<Icon type={Icons.Information} />
30+
{props.text}
31+
</div>
32+
);
33+
34+
// #endregion Component
35+
36+
// -----------------------------------------------------------------------------------------
37+
// #region Exports
38+
// -----------------------------------------------------------------------------------------
39+
40+
export { ErrorBanner };
41+
42+
// #endregion Exports

0 commit comments

Comments
 (0)