From faa5233862ad4147b7ef7f1f489efcb071abfd45 Mon Sep 17 00:00:00 2001 From: Sarka Chwastkova Date: Wed, 21 Aug 2024 16:09:37 +0200 Subject: [PATCH] chore(Modal): migrate from CSF2 to CSF3 --- .../src/Modal/Modal.stories.tsx | 1021 ++++++++--------- 1 file changed, 508 insertions(+), 513 deletions(-) diff --git a/packages/orbit-components/src/Modal/Modal.stories.tsx b/packages/orbit-components/src/Modal/Modal.stories.tsx index 713afc8035..0e8ee94ae2 100644 --- a/packages/orbit-components/src/Modal/Modal.stories.tsx +++ b/packages/orbit-components/src/Modal/Modal.stories.tsx @@ -1,6 +1,8 @@ import * as React from "react"; import { action } from "@storybook/addon-actions"; +import type { Meta, StoryObj } from "@storybook/react"; +import type { Name } from "../Illustration/types"; import Button from "../Button"; import { SIZES } from "./consts"; import Illustration from "../Illustration"; @@ -14,23 +16,64 @@ import RenderInRtl from "../utils/rtl/RenderInRtl"; import Card from "../Card"; import CarrierLogo from "../CarrierLogo"; import CardSection from "../Card/CardSection"; -import InputField from "../InputField"; -import Select from "../Select"; -import CountryFlag from "../CountryFlag"; -import InputGroup from "../InputGroup"; -import TextLink from "../TextLink"; -import Checkbox from "../Checkbox"; -import Radio from "../Radio"; import Tooltip from "../Tooltip"; import Tile from "../Tile"; import Box from "../Box"; import Modal, { ModalHeader, ModalSection, ModalFooter } from "."; -export default { +type ModalPropsAndCustomArgs = React.ComponentProps & + React.ComponentProps & + React.ComponentProps & { + showSection: boolean; + showBack: boolean; + }; + +const meta: Meta = { title: "Modal", + component: Modal, + + parameters: { + info: "Check Orbit.Kiwi for more detailed design guidelines.", + }, + + args: { + lockScrolling: false, + preventOverlayClose: false, + isMobileFullPage: false, + suppressed: false, + showBack: false, + illustration: NAMES[0], + showSection: false, + fixedFooter: false, + mobileHeader: false, + size: SIZES.NORMAL, + title: "Orbit design system", + description: "I'm lovely description", + children: + "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", + }, + + argTypes: { + size: { + options: Object.values(SIZES), + control: { + type: "select", + }, + }, + illustration: { + options: NAMES, + control: { + type: "select", + }, + }, + }, }; +type Story = StoryObj; + +export default meta; + function useModal() { const [open, toggle] = React.useReducer((_, next) => next, true); return { @@ -47,339 +90,63 @@ function useModal() { }; } -export const Sizes = ({ size, title, description, mobileHeader, content }) => { - const { Container, onClose } = useModal(); - - // const onClose = action("onClose"); - return ( - - - {description} - - {content} - - - {content} - - - {content} - - - {content} - - - - ); -}; - -Sizes.story = { - parameters: { - info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", - }, -}; - -Sizes.args = { - size: SIZES.NORMAL, - title: "Orbit design system", - description: "I'm lovely description", - mobileHeader: true, - content: - "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", -}; - -Sizes.argTypes = { - size: { - options: Object.values(SIZES), - control: { - type: "select", - }, - }, -}; - -export const ShortModal = () => { - const { Container, onClose } = useModal(); - return ( - - - - - - OUTBOUND - - - - - - Sat, Mar 31 Trip length: 1h55m - - - London LHR - - Prague PRG - - - - } - > - Hidden Content - - - - - - ); -}; - -ShortModal.story = { - parameters: { - info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", - }, -}; +export const Sizes: Story = { + render: ({ title, description, children, ...args }) => { + const { Container, onClose } = useModal(); -export const WithoutSection = ({ showMore }) => { - const { Container, onClose } = useModal(); - return ( - - - } - description="Select a flight below to see the menu (where available)" - /> - {showMore && ( + return ( + + + {description} - Lorem ipsum dolor sit amet + {children} - )} - - - - - - - ); -}; - -WithoutSection.story = { - name: "Without section", - - parameters: { - info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", + + + ); }, -}; - -WithoutSection.args = { - showMore: false, -}; - -export const RemovableSections = ({ showMore }) => { - const { Container, onClose } = useModal(); - return ( - - - } - description="Select a flight below to see the menu (where available)" - /> - {showMore && ( - - Lorem ipsum dolor sit amet - - )} - - Lorem ipsum dolor sit amet - - - - - - - - ); -}; - -RemovableSections.story = { - name: "Removable sections", - parameters: { - info: "You can try all possible configurations of this component. However, check Orbit.Kiwi for more detailed design guidelines.", + args: { + illustration: undefined, }, -}; - -RemovableSections.args = { - showMore: false, -}; -export const WithForm = ({ showMore }) => { - const { Container, onClose } = useModal(); - return ( - - - - - - - - Contact information - - - -