From 09d7e2f474678805682979d1f0069d62a324ba31 Mon Sep 17 00:00:00 2001 From: Adam Kudrna Date: Fri, 30 Oct 2020 23:52:05 +0100 Subject: [PATCH] Introduce `Card` use case with `ScrollView` (#178) --- src/lib/components/ui/Card/Card.jsx | 3 +- src/lib/components/ui/Card/CardBody.jsx | 2 +- src/lib/components/ui/Card/CardFooter.jsx | 2 +- src/lib/components/ui/Card/README.mdx | 67 +++++++++++++++---- .../ui/Card/__tests__/CardBody.test.jsx | 2 +- .../ui/Card/__tests__/CardFooter.test.jsx | 2 +- 6 files changed, 59 insertions(+), 19 deletions(-) diff --git a/src/lib/components/ui/Card/Card.jsx b/src/lib/components/ui/Card/Card.jsx index e853a7122..ea602769b 100644 --- a/src/lib/components/ui/Card/Card.jsx +++ b/src/lib/components/ui/Card/Card.jsx @@ -80,7 +80,8 @@ Card.defaultProps = { Card.propTypes = { /** - * Slot for individual Card elements that build up the inner layout: CardBody and CardFooter. + * Slot for individual Card elements that build up the inner layout: CardBody, CardFooter, or + * ScrollView. */ children: PropTypes.node.isRequired, /** diff --git a/src/lib/components/ui/Card/CardBody.jsx b/src/lib/components/ui/Card/CardBody.jsx index 27e3480bf..80a43d3b6 100644 --- a/src/lib/components/ui/Card/CardBody.jsx +++ b/src/lib/components/ui/Card/CardBody.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import styles from './Card.scss'; -const CardBody = (props) => { +export const CardBody = (props) => { const { children, } = props; diff --git a/src/lib/components/ui/Card/CardFooter.jsx b/src/lib/components/ui/Card/CardFooter.jsx index 2b229a39b..e18f8f5b5 100644 --- a/src/lib/components/ui/Card/CardFooter.jsx +++ b/src/lib/components/ui/Card/CardFooter.jsx @@ -2,7 +2,7 @@ import PropTypes from 'prop-types'; import React from 'react'; import styles from './Card.scss'; -const CardFooter = (props) => { +export const CardFooter = (props) => { const { children, } = props; diff --git a/src/lib/components/ui/Card/README.mdx b/src/lib/components/ui/Card/README.mdx index 791d61e18..3c71090ca 100644 --- a/src/lib/components/ui/Card/README.mdx +++ b/src/lib/components/ui/Card/README.mdx @@ -11,9 +11,10 @@ import { Props, } from 'docz' import { Button } from '../Button/Button' +import { ScrollView } from '../ScrollView/ScrollView' import { Card } from './Card' -import CardBody from './CardBody' -import CardFooter from './CardFooter' +import { CardBody } from './CardBody' +import { CardFooter } from './CardFooter' Cards contain content and actions about a single subject. @@ -45,15 +46,15 @@ See [API](#api) for all available options. [customize](/customize/theming) the default appearance to make it stand out on white surfaces. -- The [CardBody](#cardbody) component is the only required element in a card. - [CardFooter](#cardfooter) is optional. +- Use options [CardBody](#cardbody) and [CardFooter](#cardfooter) components to + provide your content with expected spacing. - Use **medium or low-emphasis buttons** when there are more cards, eg. in a grid. It will help you keep the UI clean and easy to scan. ## Card Composition -Aside from the mandatory [CardBody](#cardbody) element, you can add a +Aside from the [CardBody](#cardbody) element, you can add a [CardFooter](#cardfooter) to better separate your card's actions from the rest of the content. @@ -68,7 +69,7 @@ And use them: - Hello! I'm card with a footer. + Hello! I'm card with footer.