diff --git a/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx b/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx index 14c3dc4..6f348db 100644 --- a/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx +++ b/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx @@ -13,6 +13,8 @@ import { BreadcrumbItemStyles } from '../BreadcrumbItem/BreadcrumbItem.styles' import { defaultThemes, Theme, withTheme } from '../Theme' import { TypographyStyles } from '../Typography/Typography.styles' import { CardStyles } from '../Card/Card.styles' +import { CardHeaderStyles } from '../CardHeader/CardHeader.styles' +import { CardBodyStyles } from '../CardBody/CardBody.styles' const componentStyles: Array | SerializedStyles> = [ @@ -28,6 +30,8 @@ const componentStyles: Array | SerializedStyles> = BreadcrumbStyles, BreadcrumbItemStyles, CardStyles, + CardHeaderStyles, + CardBodyStyles, ] export const CSSBaseline: React.FC<{ theme?: Theme }> = ({ diff --git a/packages/lsd-react/src/components/Card/Card.stories.tsx b/packages/lsd-react/src/components/Card/Card.stories.tsx index d50c66c..43bdeac 100644 --- a/packages/lsd-react/src/components/Card/Card.stories.tsx +++ b/packages/lsd-react/src/components/Card/Card.stories.tsx @@ -1,4 +1,6 @@ import { Meta, Story } from '@storybook/react' +import { CardBody } from '../CardBody' +import { CardHeader } from '../CardHeader' import { Card, CardProps } from './Card' export default { @@ -17,20 +19,27 @@ export default { export const Root: Story = (args) => (
-
Title -
-
+ + A wise man can learn more from a foolish question than a fool can learn from a wise answer. -
+
) diff --git a/packages/lsd-react/src/components/Card/Card.tsx b/packages/lsd-react/src/components/Card/Card.tsx index 9a1b830..3f4ca34 100644 --- a/packages/lsd-react/src/components/Card/Card.tsx +++ b/packages/lsd-react/src/components/Card/Card.tsx @@ -1,5 +1,7 @@ import clsx from 'clsx' import React from 'react' +import { CardBody } from '../CardBody' +import { CardHeader } from '../CardHeader' import { cardClasses } from './Card.classes' import { CardContext } from './Card.context' @@ -9,16 +11,9 @@ export type CardProps = Omit, 'label'> & { export const Card: React.FC & { classes: typeof cardClasses -} = ({ size = 'large', children, ...props }) => { +} = ({ size = 'large', children }) => { return ( - -
- {children} -
-
+ {children} ) } diff --git a/packages/lsd-react/src/components/CardBody/CardBody.classes.ts b/packages/lsd-react/src/components/CardBody/CardBody.classes.ts new file mode 100644 index 0000000..769f34b --- /dev/null +++ b/packages/lsd-react/src/components/CardBody/CardBody.classes.ts @@ -0,0 +1,7 @@ +export const cardBodyClasses = { + root: `lsd-card-header`, + + small: `lsd-card-header--small`, + medium: `lsd-card-header--medium`, + large: `lsd-card-header--large`, +} diff --git a/packages/lsd-react/src/components/CardBody/CardBody.stories.tsx b/packages/lsd-react/src/components/CardBody/CardBody.stories.tsx new file mode 100644 index 0000000..8bb28f1 --- /dev/null +++ b/packages/lsd-react/src/components/CardBody/CardBody.stories.tsx @@ -0,0 +1,28 @@ +import { Meta, Story } from '@storybook/react' +import { CardBody, CardBodyProps } from './CardBody' + +export default { + title: 'CardBody', + component: CardBody, + argTypes: { + size: { + type: { + name: 'enum', + value: ['small', 'medium', 'large'], + }, + }, + }, +} as Meta + +export const Root: Story = (args) => ( +
+ + A wise man can learn more from a foolish question than a fool can learn + from a wise answer. + +
+) + +Root.args = { + size: 'large', +} diff --git a/packages/lsd-react/src/components/CardBody/CardBody.styles.ts b/packages/lsd-react/src/components/CardBody/CardBody.styles.ts new file mode 100644 index 0000000..588d36d --- /dev/null +++ b/packages/lsd-react/src/components/CardBody/CardBody.styles.ts @@ -0,0 +1,14 @@ +import { css } from '@emotion/react' +import { cardBodyClasses } from './CardBody.classes' + +export const CardBodyStyles = css` + .${cardBodyClasses.root} { + box-sizing: border-box; + } + .${cardBodyClasses.large} { + } + .${cardBodyClasses.medium} { + } + .${cardBodyClasses.small} { + } +` diff --git a/packages/lsd-react/src/components/CardBody/CardBody.tsx b/packages/lsd-react/src/components/CardBody/CardBody.tsx new file mode 100644 index 0000000..b1f688b --- /dev/null +++ b/packages/lsd-react/src/components/CardBody/CardBody.tsx @@ -0,0 +1,32 @@ +import clsx from 'clsx' +import React from 'react' +import { useCardContext } from '../Card/Card.context' +import { cardBodyClasses } from './CardBody.classes' + +export type CardBodyProps = Omit< + React.HTMLAttributes, + 'label' +> & { + size?: 'small' | 'medium' | 'large' +} + +export const CardBody: React.FC & { + classes: typeof cardBodyClasses +} = ({ size: _size = 'large', children, ...props }) => { + const sizeContext = useCardContext() + const size = sizeContext?.size ?? _size + return ( +
+ {children} +
+ ) +} + +CardBody.classes = cardBodyClasses diff --git a/packages/lsd-react/src/components/CardBody/index.ts b/packages/lsd-react/src/components/CardBody/index.ts new file mode 100644 index 0000000..b81eecf --- /dev/null +++ b/packages/lsd-react/src/components/CardBody/index.ts @@ -0,0 +1 @@ +export * from './CardBody' diff --git a/packages/lsd-react/src/components/CardHeader/CardHeader.classes.ts b/packages/lsd-react/src/components/CardHeader/CardHeader.classes.ts new file mode 100644 index 0000000..8d0d7d1 --- /dev/null +++ b/packages/lsd-react/src/components/CardHeader/CardHeader.classes.ts @@ -0,0 +1,7 @@ +export const cardHeaderClasses = { + root: `lsd-card-header`, + + small: `lsd-card-header--small`, + medium: `lsd-card-header--medium`, + large: `lsd-card-header--large`, +} diff --git a/packages/lsd-react/src/components/CardHeader/CardHeader.stories.tsx b/packages/lsd-react/src/components/CardHeader/CardHeader.stories.tsx new file mode 100644 index 0000000..bf379d2 --- /dev/null +++ b/packages/lsd-react/src/components/CardHeader/CardHeader.stories.tsx @@ -0,0 +1,25 @@ +import { Meta, Story } from '@storybook/react' +import { CardHeader, CardHeaderProps } from './CardHeader' + +export default { + title: 'CardHeader', + component: CardHeader, + argTypes: { + size: { + type: { + name: 'enum', + value: ['small', 'medium', 'large'], + }, + }, + }, +} as Meta + +export const Root: Story = (args) => ( +
+ Title +
+) + +Root.args = { + size: 'large', +} diff --git a/packages/lsd-react/src/components/CardHeader/CardHeader.styles.ts b/packages/lsd-react/src/components/CardHeader/CardHeader.styles.ts new file mode 100644 index 0000000..da64300 --- /dev/null +++ b/packages/lsd-react/src/components/CardHeader/CardHeader.styles.ts @@ -0,0 +1,14 @@ +import { css } from '@emotion/react' +import { cardHeaderClasses } from './CardHeader.classes' + +export const CardHeaderStyles = css` + .${cardHeaderClasses.root} { + box-sizing: border-box; + } + .${cardHeaderClasses.large} { + } + .${cardHeaderClasses.medium} { + } + .${cardHeaderClasses.small} { + } +` diff --git a/packages/lsd-react/src/components/CardHeader/CardHeader.tsx b/packages/lsd-react/src/components/CardHeader/CardHeader.tsx new file mode 100644 index 0000000..b35c70f --- /dev/null +++ b/packages/lsd-react/src/components/CardHeader/CardHeader.tsx @@ -0,0 +1,32 @@ +import clsx from 'clsx' +import React from 'react' +import { useCardContext } from '../Card/Card.context' +import { cardHeaderClasses } from './CardHeader.classes' + +export type CardHeaderProps = Omit< + React.HTMLAttributes, + 'label' +> & { + size?: 'small' | 'medium' | 'large' +} + +export const CardHeader: React.FC & { + classes: typeof cardHeaderClasses +} = ({ size: _size = 'large', children, ...props }) => { + const sizeContext = useCardContext() + const size = sizeContext?.size ?? _size + return ( +
+ {children} +
+ ) +} + +CardHeader.classes = cardHeaderClasses diff --git a/packages/lsd-react/src/components/CardHeader/index.ts b/packages/lsd-react/src/components/CardHeader/index.ts new file mode 100644 index 0000000..f953341 --- /dev/null +++ b/packages/lsd-react/src/components/CardHeader/index.ts @@ -0,0 +1 @@ +export * from './CardHeader' diff --git a/packages/lsd-react/src/index.ts b/packages/lsd-react/src/index.ts index 20e1306..fae6404 100644 --- a/packages/lsd-react/src/index.ts +++ b/packages/lsd-react/src/index.ts @@ -10,3 +10,5 @@ export * from './components/Theme' export * from './components/Breadcrumb' export * from './components/BreadcrumbItem' export * from './components/Card' +export * from './components/CardHeader' +export * from './components/CardBody'