diff --git a/src/atoms/Card/Card.stories.js b/src/atoms/Card/Card.stories.js index 443a21d5..4a61a6ad 100644 --- a/src/atoms/Card/Card.stories.js +++ b/src/atoms/Card/Card.stories.js @@ -9,10 +9,6 @@ const ShortDiv = styled('div')({ }, }); -const LongDiv = styled('div')({ - height: '600px', -}); - export default (asStory) => { asStory('ATOMS/Card', module, (story, { Card }) => { story @@ -36,6 +32,17 @@ export default (asStory) => { Body



)) + .add('without multiple sections', () => ( + + Header + + Section



+ Section



+ Section



+
+ Footer +
+ )) .add('without header', () => ( Body



@@ -46,10 +53,10 @@ export default (asStory) => { Header - - - Body - + + Section







+ Section







+ Section







Footer
diff --git a/src/atoms/Card/CardBody.js b/src/atoms/Card/CardBody.js index 89843dd6..7eb77901 100644 --- a/src/atoms/Card/CardBody.js +++ b/src/atoms/Card/CardBody.js @@ -1,5 +1,6 @@ // @flow import React from 'react'; + import { createStyledTag, createTheme } from '../../utils'; import { offsetModifier } from './common'; import type { PropSizes } from '../../types'; diff --git a/src/atoms/Card/CardSection.js b/src/atoms/Card/CardSection.js new file mode 100644 index 00000000..5602acaf --- /dev/null +++ b/src/atoms/Card/CardSection.js @@ -0,0 +1,44 @@ +// @flow +import React from 'react'; + +import { COLORS } from '../../theme'; +import { createStyledTag, createTheme } from '../../utils'; +import { offsetModifier } from './common'; +import type { PropSizes } from '../../types'; + +type CardSectionProps = {| + children: React$Node, + padding?: PropSizes, + stretch?: boolean, +|}; + +const name = 'cardSection'; + +const cardSectionTheme = createTheme(name, { + modifiers: { + stretch: { + display: 'flex', + flex: 1, + width: '100%', + }, + ...offsetModifier, + }, +}); + +const CardSectionTag = createStyledTag(name, { + '&:not(:last-child)': { + borderBottom: `1px solid ${COLORS.PRIMARY_BORDER_COLOR}`, + }, +}); + +const CardSection = ({ children, ...rest }: CardSectionProps) => ( + + { children } + +); + +CardSection.defaultProps = { + padding: 'md', +}; + +export { cardSectionTheme, CardSection }; diff --git a/src/atoms/Card/index.js b/src/atoms/Card/index.js index 7f446753..0a640c4f 100644 --- a/src/atoms/Card/index.js +++ b/src/atoms/Card/index.js @@ -3,18 +3,21 @@ import { CardPlate } from './CardPlate'; import { CardHeader, cardHeaderTheme } from './CardHeader'; import { CardBody, cardBodyTheme } from './CardBody'; +import { CardSection, cardSectionTheme } from './CardSection'; import { CardFooter, cardFooterTheme } from './CardFooter'; const Card = { Plate: CardPlate, Header: CardHeader, Body: CardBody, + Section: CardSection, Footer: CardFooter, }; const theme = { ...cardHeaderTheme, ...cardBodyTheme, + ...cardSectionTheme, ...cardFooterTheme, }; diff --git a/storybook/__tests__/__snapshots__/storyshots.test.js.snap b/storybook/__tests__/__snapshots__/storyshots.test.js.snap index 59a9ffb4..c4591ba0 100644 --- a/storybook/__tests__/__snapshots__/storyshots.test.js.snap +++ b/storybook/__tests__/__snapshots__/storyshots.test.js.snap @@ -1885,11 +1885,11 @@ exports[`Storyshots ATOMS/Card with custom offsets 1`] = ` `; exports[`Storyshots ATOMS/Card with scrollable body 1`] = ` -.emotion-6 { +.emotion-8 { margin: 2rem; } -.emotion-4 { +.emotion-6 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -1922,7 +1922,7 @@ exports[`Storyshots ATOMS/Card with scrollable body 1`] = ` padding: 2rem; } -.emotion-3 { +.emotion-5 { border-top: 1px solid #d0d7dd; -webkit-flex-shrink: 0; -ms-flex-negative: 0; @@ -1930,32 +1930,36 @@ exports[`Storyshots ATOMS/Card with scrollable body 1`] = ` padding: 2rem; } -.emotion-5 { +.emotion-1 { + padding: 2rem; +} + +.emotion-1:not(:last-child) { + border-bottom: 1px solid #d0d7dd; +} + +.emotion-7 { height: 300px; max-height: 300px; } -.emotion-5 > * { +.emotion-7 > * { max-height: 100%; } -.emotion-2 { +.emotion-4 { overflow: auto; - padding: 2rem; -} - -.emotion-1 { - height: 600px; + padding: 0px; }
- Body + Section +
+
+
+
+
+
+
+
+
+
+ Section +
+
+
+
+
+
+
+
+
+
+ Section +
+
+
+
+
+
+
+
Footer
@@ -2104,6 +2142,115 @@ exports[`Storyshots ATOMS/Card without header 1`] = `
`; +exports[`Storyshots ATOMS/Card without multiple sections 1`] = ` +.emotion-7 { + margin: 2rem; +} + +.emotion-6 { + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-flex-direction: column; + -ms-flex-direction: column; + flex-direction: column; + background: #FFFFFF; + color: #000000; + box-shadow: 0 1px 3px 0 rgba(50,50,93,.14),0 4px 6px 0 rgba(112,157,199,.08); + position: relative; + padding: 0px; + border-radius: .5rem; +} + +.emotion-0 { + border-bottom: 1px solid #d0d7dd; + display: -webkit-box; + display: -webkit-flex; + display: -ms-flexbox; + display: flex; + -webkit-align-items: center; + -webkit-box-align: center; + -ms-flex-align: center; + align-items: center; + position: relative; + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; + padding: 2rem; +} + +.emotion-5 { + border-top: 1px solid #d0d7dd; + -webkit-flex-shrink: 0; + -ms-flex-negative: 0; + flex-shrink: 0; + padding: 2rem; +} + +.emotion-4 { + padding: 0px; +} + +.emotion-1 { + padding: 2rem; +} + +.emotion-1:not(:last-child) { + border-bottom: 1px solid #d0d7dd; +} + +
+
+
+ Header +
+
+
+ Section +
+
+
+
+
+
+ Section +
+
+
+
+
+
+ Section +
+
+
+
+
+
+
+ Footer +
+
+
+`; + exports[`Storyshots ATOMS/DATA ENTRY/Checkbox with check 1`] = ` .emotion-6 { margin: 2rem;