diff --git a/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx b/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx index 97e2b6d..d355713 100644 --- a/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx +++ b/packages/lsd-react/src/components/CSSBaseline/CSSBaseline.tsx @@ -34,6 +34,8 @@ import { defaultThemes, Theme, withTheme } from '../Theme' import { TypographyStyles } from '../Typography/Typography.styles' import { NumberInputStyles } from '../NumberInput/NumberInput.styles' import { ModalStyles } from '../Modal/Modal.styles' +import { ModalFooterStyles } from '../ModalFooter/ModalFooter.styles' +import { ModalBody } from '../ModalBody' import { ModalBodyStyles } from '../ModalBody/ModalBody.styles' const componentStyles: Array | SerializedStyles> = @@ -71,6 +73,7 @@ const componentStyles: Array | SerializedStyles> = TableRowStyles, NumberInputStyles, ModalStyles, + ModalFooterStyles, ModalBodyStyles, ] diff --git a/packages/lsd-react/src/components/Modal/Modal.classes.ts b/packages/lsd-react/src/components/Modal/Modal.classes.ts index 0d6ab9e..b34b293 100644 --- a/packages/lsd-react/src/components/Modal/Modal.classes.ts +++ b/packages/lsd-react/src/components/Modal/Modal.classes.ts @@ -4,7 +4,7 @@ export const modalClasses = { small: 'lsd-modal--small', medium: 'lsd-modal--medium', large: 'lsd-modal--large', - extraSmall: 'lsd-modal--extra-small', + xsmall: 'lsd-modal--extra-small', modalContainer: 'lsd-modal__container', diff --git a/packages/lsd-react/src/components/Modal/Modal.stories.tsx b/packages/lsd-react/src/components/Modal/Modal.stories.tsx index ad24388..ed845a4 100644 --- a/packages/lsd-react/src/components/Modal/Modal.stories.tsx +++ b/packages/lsd-react/src/components/Modal/Modal.stories.tsx @@ -1,8 +1,9 @@ -import React, { useState } from 'react' +import { useState } from 'react' import { Meta, Story } from '@storybook/react' -import { ModalBody } from '../ModalBody' import { Modal, ModalProps } from './Modal' import { Button } from '../Button' +import { ModalBody } from '../ModalBody' +import { ModalFooter } from '../ModalFooter' export default { title: 'Modal', @@ -11,7 +12,7 @@ export default { size: { type: { name: 'enum', - value: ['extraSmall', 'small', 'medium', 'large'], + value: ['xsmall', 'small', 'medium', 'large'], }, }, }, @@ -23,25 +24,37 @@ export const Root: Story< } > = ({ body, ...args }) => { const [isOpen, setIsOpen] = useState(false) + const slotStyles: React.CSSProperties = { + boxSizing: 'border-box', + display: 'flex', + flexDirection: 'column', + justifyContent: 'center', + alignItems: 'center', + border: '1px solid rgb(var(--lsd-border-primary)', + padding: '30px', + } return (
setIsOpen(false)}> - {body} -
+ +
{body}
+
+ + - -
+
) diff --git a/packages/lsd-react/src/components/Modal/Modal.styles.ts b/packages/lsd-react/src/components/Modal/Modal.styles.ts index eaa09f2..f10c1d0 100644 --- a/packages/lsd-react/src/components/Modal/Modal.styles.ts +++ b/packages/lsd-react/src/components/Modal/Modal.styles.ts @@ -69,7 +69,7 @@ export const ModalStyles = css` } } - .${modalClasses.extraSmall} { + .${modalClasses.xsmall} { .${modalClasses.modalContainer} { min-width: 490px; } diff --git a/packages/lsd-react/src/components/Modal/Modal.tsx b/packages/lsd-react/src/components/Modal/Modal.tsx index ab3bff9..790328e 100644 --- a/packages/lsd-react/src/components/Modal/Modal.tsx +++ b/packages/lsd-react/src/components/Modal/Modal.tsx @@ -1,5 +1,5 @@ import clsx from 'clsx' -import React from 'react' +import React, { ReactNode } from 'react' import { CommonProps, omitCommonProps, @@ -13,9 +13,9 @@ import { IconButton } from '../IconButton' export type ModalProps = CommonProps & Omit, 'label'> & { isOpen: boolean - size?: 'extraSmall' | 'small' | 'medium' | 'large' - title?: string - subtitle?: string + size?: 'xsmall' | 'small' | 'medium' | 'large' + title?: ReactNode + subtitle?: ReactNode onClose?: () => void } @@ -67,7 +67,7 @@ export const Modal: React.FC & { {!!subtitle && ( diff --git a/packages/lsd-react/src/components/ModalBody/ModalBody.stories.tsx b/packages/lsd-react/src/components/ModalBody/ModalBody.stories.tsx index 5dcff29..09fb055 100644 --- a/packages/lsd-react/src/components/ModalBody/ModalBody.stories.tsx +++ b/packages/lsd-react/src/components/ModalBody/ModalBody.stories.tsx @@ -15,16 +15,23 @@ export default { export const Root: Story< ModalBodyProps & { - body: string - title: string + content: string } -> = ({ body, ...args }) => ( -
- {body} -
-) +> = ({ content, ...args }) => { + const bodyStyle: React.CSSProperties = { + boxSizing: 'border-box', + border: '1px solid rgb(var(--lsd-border-primary)', + padding: '30px', + } + + return ( + + {content} + + ) +} Root.args = { - title: 'Title', - body: 'A wise man can learn more from a foolish question than a fool can learn from a wise answer.', + content: + '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/ModalBody/ModalBody.styles.ts b/packages/lsd-react/src/components/ModalBody/ModalBody.styles.ts index 3f3a844..03ae6c1 100644 --- a/packages/lsd-react/src/components/ModalBody/ModalBody.styles.ts +++ b/packages/lsd-react/src/components/ModalBody/ModalBody.styles.ts @@ -3,14 +3,6 @@ import { modalBodyClasses } from './ModalBody.classes' export const ModalBodyStyles = css` .${modalBodyClasses.root} { - box-sizing: border-box; - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - - border: 1px solid rgb(var(--lsd-border-primary)); - padding: 30px; margin: 18px 0; } ` diff --git a/packages/lsd-react/src/components/ModalFooter/ModalFooter.classes.ts b/packages/lsd-react/src/components/ModalFooter/ModalFooter.classes.ts new file mode 100644 index 0000000..7df1a80 --- /dev/null +++ b/packages/lsd-react/src/components/ModalFooter/ModalFooter.classes.ts @@ -0,0 +1,3 @@ +export const modalFooterClasses = { + root: `lsd-modal-footer`, +} diff --git a/packages/lsd-react/src/components/ModalFooter/ModalFooter.stories.tsx b/packages/lsd-react/src/components/ModalFooter/ModalFooter.stories.tsx new file mode 100644 index 0000000..b9bd310 --- /dev/null +++ b/packages/lsd-react/src/components/ModalFooter/ModalFooter.stories.tsx @@ -0,0 +1,48 @@ +import { Meta, Story } from '@storybook/react' +import { ModalFooter, ModalFooterProps } from './ModalFooter' +import { Button } from '../Button' + +export default { + title: 'ModalFooter', + component: ModalFooter, + argTypes: { + size: { + type: { + name: 'enum', + value: ['xsmall', 'small', 'medium', 'large'], + }, + }, + }, +} as Meta + +export const Root: Story< + ModalFooterProps & { + size: 'xsmall' | 'small' | 'medium' | 'large' + } +> = ({ size, ...args }) => { + const footerStyle: React.CSSProperties = { + boxSizing: 'border-box', + border: '1px solid rgb(var(--lsd-border-primary)', + padding: '30px', + } + + return ( + + + + + + + ) +} + +Root.args = { + size: 'large', +} diff --git a/packages/lsd-react/src/components/ModalFooter/ModalFooter.styles.ts b/packages/lsd-react/src/components/ModalFooter/ModalFooter.styles.ts new file mode 100644 index 0000000..2671ba3 --- /dev/null +++ b/packages/lsd-react/src/components/ModalFooter/ModalFooter.styles.ts @@ -0,0 +1,8 @@ +import { css } from '@emotion/react' +import { modalFooterClasses } from './ModalFooter.classes' + +export const ModalFooterStyles = css` + .${modalFooterClasses.root} { + display: flex; + } +` diff --git a/packages/lsd-react/src/components/ModalFooter/ModalFooter.tsx b/packages/lsd-react/src/components/ModalFooter/ModalFooter.tsx new file mode 100644 index 0000000..809370a --- /dev/null +++ b/packages/lsd-react/src/components/ModalFooter/ModalFooter.tsx @@ -0,0 +1,28 @@ +import clsx from 'clsx' +import React from 'react' +import { + CommonProps, + omitCommonProps, + useCommonProps, +} from '../../utils/useCommonProps' +import { modalFooterClasses } from './ModalFooter.classes' + +export type ModalFooterProps = CommonProps & + Omit, 'label'> + +export const ModalFooter: React.FC & { + classes: typeof modalFooterClasses +} = ({ children, ...props }) => { + const commonProps = useCommonProps(props) + + return ( +
+ {children} +
+ ) +} + +ModalFooter.classes = modalFooterClasses diff --git a/packages/lsd-react/src/components/ModalFooter/index.ts b/packages/lsd-react/src/components/ModalFooter/index.ts new file mode 100644 index 0000000..f2d8273 --- /dev/null +++ b/packages/lsd-react/src/components/ModalFooter/index.ts @@ -0,0 +1 @@ +export * from './ModalFooter' diff --git a/packages/lsd-react/src/index.ts b/packages/lsd-react/src/index.ts index e251e7e..eac4843 100644 --- a/packages/lsd-react/src/index.ts +++ b/packages/lsd-react/src/index.ts @@ -33,3 +33,4 @@ export * from './components/Typography' export * from './components/NumberInput' export * from './components/Modal' export * from './components/ModalBody' +export * from './components/ModalFooter'