File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -54,6 +54,15 @@ export * from "./atoms/interfaces/svg-icon";
5454
5555// #endregion Interfaces
5656
57+ // -----------------------------------------------------------------------------------------
58+ // #region Molecules
59+ // -----------------------------------------------------------------------------------------
60+
61+ export { AccessibleList } from "./molecules/accessible-list/accessible-list" ;
62+ export { Card } from "./molecules/cards/card" ;
63+
64+ // #endregion Molecules
65+
5766// -----------------------------------------------------------------------------------------
5867// #region Types
5968// -----------------------------------------------------------------------------------------
Original file line number Diff line number Diff line change 1+ import { Card } from "./card" ;
2+ import React from "react" ;
3+ import { text } from "@storybook/addon-knobs" ;
4+
5+ export default {
6+ component : Card ,
7+ title : "Molecules | Cards / Cards" ,
8+ } ;
9+
10+ export const cardDefault = ( ) => (
11+ < Card label = "Card Label" > { text ( "content" , "Card Content" ) } </ Card >
12+ ) ;
Original file line number Diff line number Diff line change 1+ import React from "react" ;
2+ import { render } from "@testing-library/react" ;
3+ import { Card } from "./card" ;
4+ import faker from "faker" ;
5+
6+ describe ( "Card" , ( ) => {
7+ test ( "when default props, renders card" , ( ) => {
8+ // Arrange
9+ const expected = faker . random . words ( ) ;
10+
11+ // Act
12+ const { getByText } = render ( < Card label = { expected } /> ) ;
13+
14+ // Assert
15+ expect ( getByText ( expected ) ) . not . toBeNull ( ) ;
16+ } ) ;
17+
18+ test ( "when default props with children, renders card" , ( ) => {
19+ // Arrange
20+ const label = faker . random . words ( ) ;
21+ const expected = faker . random . words ( ) ;
22+
23+ // Act
24+ const { getByText } = render ( < Card label = { label } > { expected } </ Card > ) ;
25+
26+ // Assert
27+ expect ( getByText ( expected ) ) . not . toBeNull ( ) ;
28+ } ) ;
29+ } ) ;
Original file line number Diff line number Diff line change 1+ import React , { PropsWithChildren } from "react" ;
2+ import { Paragraph } from "../../atoms/typography/paragraph" ;
3+
4+ // -------------------------------------------------------------------------------------------------
5+ // #region Constants
6+ // -------------------------------------------------------------------------------------------------
7+
8+ const COMPONENT_CLASS = "c-card" ;
9+
10+ // #endregion Constants
11+
12+ // -------------------------------------------------------------------------------------------------
13+ // #region Interfaces
14+ // -------------------------------------------------------------------------------------------------
15+
16+ export interface CardProps {
17+ label : string ;
18+ }
19+
20+ // #endregion Interfaces
21+
22+ // -------------------------------------------------------------------------------------------------
23+ // #region Components
24+ // -------------------------------------------------------------------------------------------------
25+
26+ const Card : React . FC < CardProps > = ( props : PropsWithChildren < CardProps > ) => (
27+ < div className = { COMPONENT_CLASS } >
28+ < div className = { `${ COMPONENT_CLASS } __content` } >
29+ < Paragraph > { props . children } </ Paragraph >
30+ </ div >
31+ < div className = { `${ COMPONENT_CLASS } __label` } >
32+ < Paragraph > { props . label } </ Paragraph >
33+ </ div >
34+ </ div >
35+ ) ;
36+
37+ // #endregion Components
38+
39+ // -------------------------------------------------------------------------------------------------
40+ // #region Exports
41+ // -------------------------------------------------------------------------------------------------
42+
43+ export { Card } ;
44+
45+ // #endregion Exports
You can’t perform that action at this time.
0 commit comments