From 8be81c20319a76779d750fec38ad2c237709762a Mon Sep 17 00:00:00 2001 From: Aleksandr Shumilov Date: Tue, 8 Aug 2023 21:01:41 +0200 Subject: [PATCH] feat: add xsmall and xlarge modal sizes --- cypress/component/Modal.spec.tsx | 31 ++++++++++--------- packages/picasso/src/Modal/Modal.tsx | 4 ++- .../picasso/src/Modal/story/Sizes.example.tsx | 28 +++++++++++++++++ packages/picasso/src/Modal/styles.ts | 6 ++++ 4 files changed, 54 insertions(+), 15 deletions(-) diff --git a/cypress/component/Modal.spec.tsx b/cypress/component/Modal.spec.tsx index 5daab07638d..338a33ce9f7 100644 --- a/cypress/component/Modal.spec.tsx +++ b/cypress/component/Modal.spec.tsx @@ -217,21 +217,24 @@ describe('Modal', () => { const { width } = happoTarget describe(`when screen has ${width}px width`, () => { - Cypress._.each(['small', 'medium', 'large', 'full-screen'], modalSize => { - it(`renders ${modalSize} size modal`, () => { - cy.viewport(width, 1000) - - cy.mount( - - ) - - cy.get('body').happoScreenshot({ - component, - variant: `modal-${modalSize}-size/${width}-default`, - targets: [happoTarget], + Cypress._.each( + ['xsmall', 'small', 'medium', 'large', 'xlarge', 'full-screen'], + modalSize => { + it(`renders ${modalSize} size modal`, () => { + cy.viewport(width, 1000) + + cy.mount( + + ) + + cy.get('body').happoScreenshot({ + component, + variant: `modal-${modalSize}-size/${width}-default`, + targets: [happoTarget], + }) }) - }) - }) + } + ) }) }) }) diff --git a/packages/picasso/src/Modal/Modal.tsx b/packages/picasso/src/Modal/Modal.tsx index 94e53200fdd..478b7429347 100644 --- a/packages/picasso/src/Modal/Modal.tsx +++ b/packages/picasso/src/Modal/Modal.tsx @@ -39,7 +39,9 @@ export interface Props extends StandardProps, HTMLAttributes { /** Whether modal should be displayed */ open: boolean /** Width of modal */ - size?: SizeType<'small' | 'medium' | 'large'> | 'full-screen' + size?: + | SizeType<'xsmall' | 'small' | 'medium' | 'large' | 'xlarge'> + | 'full-screen' /** Callback executed when backdrop was clicked */ onBackdropClick?: () => void /** If `true`, clicking the backdrop will not fire `onClose` or `onBackdropClick` */ diff --git a/packages/picasso/src/Modal/story/Sizes.example.tsx b/packages/picasso/src/Modal/story/Sizes.example.tsx index 631460fd5f8..789d8316f36 100644 --- a/packages/picasso/src/Modal/story/Sizes.example.tsx +++ b/packages/picasso/src/Modal/story/Sizes.example.tsx @@ -59,6 +59,11 @@ const ModalDialog = ({ ) const Example = () => { + const { + showModal: showModalExtraSmall, + hideModal: hideModalExtraSmall, + isOpen: isOpenExtraSmall, + } = useModal() const { showModal: showModalSmall, hideModal: hideModalSmall, @@ -74,6 +79,11 @@ const Example = () => { hideModal: hideModalLarge, isOpen: isOpenLarge, } = useModal() + const { + showModal: showModalExtraLarge, + hideModal: hideModalExtraLarge, + isOpen: isOpenExtraLarge, + } = useModal() const { showModal: showModalFullscreen, hideModal: hideModalFullscreen, @@ -82,6 +92,15 @@ const Example = () => { return ( + + + @@ -101,6 +120,15 @@ const Example = () => { + + + diff --git a/packages/picasso/src/Modal/styles.ts b/packages/picasso/src/Modal/styles.ts index cd1fcf3277f..99177144a48 100644 --- a/packages/picasso/src/Modal/styles.ts +++ b/packages/picasso/src/Modal/styles.ts @@ -32,6 +32,9 @@ export default ({ screens, sizes }: Theme) => maxWidth, }, }, + xsmall: { + width: '20.5rem', + }, small: { width: '32.5rem', }, @@ -41,6 +44,9 @@ export default ({ screens, sizes }: Theme) => large: { width: '50rem', }, + xlarge: { + width: '75rem', + }, 'full-screen': { height: '100%', width: '100%',