Skip to content

Commit edf0c26

Browse files
Implement the EmptyState component
This commit implements the actual empty state component that consists of the styled components and provides the rendered output and logic. GH-78
1 parent c32d119 commit edf0c26

File tree

3 files changed

+93
-0
lines changed

3 files changed

+93
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
3+
* Copyright (C) 2018-present Sven Greb <[email protected]>
4+
*
5+
* Project: Nord Docs
6+
* Repository: https://github.com/arcticicestudio/nord-docs
7+
* License: MIT
8+
*/
9+
10+
import React from "react";
11+
import PropTypes from "prop-types";
12+
13+
import { Headline, Illustration, Subline, TextWrapper, Wrapper } from "./styled";
14+
15+
/**
16+
* A component that represents an empty state through a vector illustration with a headline and subline.
17+
* The illustration that'll be shown can be configured through the `illustrationVariant` prop and styled with
18+
* styled-component's `css` API passed to the `illustrationStyles` prop.
19+
*
20+
* @author Arctic Ice Studio <[email protected]>
21+
* @author Sven Greb <[email protected]>
22+
* @see https://material.io/design/communication/empty-states.html
23+
* @since 0.3.0
24+
*/
25+
const EmptyState = ({ headline, illustrationStyles, illustrationVariant, subline, ...passProps }) => (
26+
<Wrapper {...passProps}>
27+
<Illustration illustrationStyles={illustrationStyles} illustrationVariant={illustrationVariant} />
28+
<TextWrapper>
29+
<Headline>{headline}</Headline>
30+
<Subline>{subline}</Subline>
31+
</TextWrapper>
32+
</Wrapper>
33+
);
34+
35+
EmptyState.propTypes = {
36+
headline: PropTypes.string.isRequired,
37+
subline: PropTypes.string.isRequired
38+
};
39+
40+
export default EmptyState;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
/*
2+
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
3+
* Copyright (C) 2018-present Sven Greb <[email protected]>
4+
*
5+
* Project: Nord Docs
6+
* Repository: https://github.com/arcticicestudio/nord-docs
7+
* License: MIT
8+
*/
9+
10+
export { default } from "./EmptyState";
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
* Copyright (C) 2018-present Arctic Ice Studio <[email protected]>
3+
* Copyright (C) 2018-present Sven Greb <[email protected]>
4+
*
5+
* Project: Nord Docs
6+
* Repository: https://github.com/arcticicestudio/nord-docs
7+
* License: MIT
8+
*/
9+
10+
import React from "react";
11+
import { waitForElement } from "react-testing-library";
12+
13+
import { renderWithTheme } from "nord-docs-test-utils";
14+
import EmptyState from "molecules/core/EmptyState";
15+
16+
const emptyStateIllustrationStylesMock = [];
17+
18+
describe("rendering", () => {
19+
test("renders the headline and subline", async () => {
20+
const { getByText } = renderWithTheme(
21+
<EmptyState
22+
headline="The arctic winter"
23+
illustrationStyles={emptyStateIllustrationStylesMock}
24+
subline="A beautiful sparkly phenomenon!"
25+
/>
26+
);
27+
28+
await waitForElement(() => getByText(/The arctic winter/i));
29+
await waitForElement(() => getByText(/A beautiful sparkly phenomenon!/i));
30+
});
31+
32+
test("renders the illustration", async () => {
33+
const { getByTestId } = renderWithTheme(
34+
<EmptyState
35+
headline="The arctic winter"
36+
illustrationStyles={emptyStateIllustrationStylesMock}
37+
subline="A beautiful sparkly phenomenon!"
38+
/>
39+
);
40+
41+
await waitForElement(() => getByTestId("nd-molecules-core-emptystate-styled-svg-igloo-front"));
42+
});
43+
});

0 commit comments

Comments
 (0)