From ac288201774c03cb6b143270ac56865d6684fc4b Mon Sep 17 00:00:00 2001 From: Dominika Hustinova Date: Mon, 12 Aug 2024 13:40:36 +0200 Subject: [PATCH] chore(InputGroup): migrate stories from CSF2 to CSF3 --- .../src/InputGroup/InputGroup.stories.tsx | 402 ++++++++---------- 1 file changed, 177 insertions(+), 225 deletions(-) diff --git a/packages/orbit-components/src/InputGroup/InputGroup.stories.tsx b/packages/orbit-components/src/InputGroup/InputGroup.stories.tsx index 0100d8da0c..60f6fa2074 100644 --- a/packages/orbit-components/src/InputGroup/InputGroup.stories.tsx +++ b/packages/orbit-components/src/InputGroup/InputGroup.stories.tsx @@ -1,20 +1,60 @@ import * as React from "react"; +import type { Meta, StoryObj } from "@storybook/react"; import { action } from "@storybook/addon-actions"; import Stack from "../Stack"; import InputField from "../InputField"; import Select from "../Select"; -import { SIZE_OPTIONS } from "./consts"; import CountryFlag from "../CountryFlag"; import RenderInRtl from "../utils/rtl/RenderInRtl"; import { SPACINGS_AFTER } from "../common/consts"; import InputGroup from "."; -export default { +type InputGroupPropsAndCustomArgs = React.ComponentProps & { + customValueText?: React.ReactNode; + inputValue?: string | number; + placeholder?: string; + selectValue?: string | number; + errorGroup?: string; + helpGroup?: string; + errorSingleField?: string; + helpSingleField?: string; +}; + +const meta: Meta = { title: "InputGroup", + component: InputGroup, + + parameters: { + controls: { + exclude: ["onChange", "onFocus", "onBlur", "onBlurGroup", "size"], + }, + }, + + args: { + error: "", + help: "", + helpClosable: true, + onChange: action("onChange"), + onFocus: action("onFocus"), + onBlur: action("onBlur"), + onBlurGroup: action("onBlurGroup"), + }, + + argTypes: { + spaceAfter: { + options: Object.values(SPACINGS_AFTER), + control: { + type: "select", + }, + }, + }, }; +export default meta; +type Story = StoryObj; + const selectOptionsMonths = [ { value: "January", label: "January" }, { value: "February", label: "February" }, @@ -30,16 +70,9 @@ const selectOptionsMonths = [ { value: "December", label: "December" }, ]; -export const DateOfBirth = ({ label, flex, error, help, selectValue }) => { - return ( - +export const DateOfBirth: Story = { + render: ({ error, help, selectValue, ...args }) => ( + { - ); -}; - -PhoneNumber.story = { - name: "Phone number", - - parameters: { - info: "Some description about this type of InputGroup in general.", + ), + + args: { + flex: ["0 0 110px", "1 1 100%"], + selectValue: selectOptionsPhoneNumber[0].value, + customValueText: "+420", + placeholder: "e.g. 123 456 789", + inputValue: "", }, -}; -PhoneNumber.args = { - flex: ["0 0 110px", "1 1 100%"], - error: "", - help: "", - selectValue: selectOptionsPhoneNumber[0].value, - customValueText: "+420", - placeholder: "e.g. 123 456 789", - inputValue: "", -}; - -PhoneNumber.argTypes = { - selectValue: { - options: selectOptionsPhoneNumber.map(opt => opt.value), - control: { - type: "select", + argTypes: { + selectValue: { + options: selectOptionsPhoneNumber.map(opt => opt.value), + control: { + type: "select", + }, }, }, }; @@ -155,53 +155,41 @@ const selectOptionsError = [ { value: "November", label: "November" }, { value: "December", label: "December" }, ]; -export const Error = ({ label, flex, error, help, selectValue }) => { - return ( - + +export const Error: Story = { + render: ({ error, help, selectValue, ...args }) => ( + - ); -}; - -Rtl.story = { - name: "RTL", + ), parameters: { info: "This is a preview of this component in RTL setup.", }, -}; -Rtl.args = { - flex: ["0 0 60px", "1 1 100%", "0 0 90px"], - selectValue: selectOptionsMonths[0].value, - error: "", - help: "", - label: "Phone number", -}; + args: { + label: "Phone number", + flex: ["0 0 60px", "1 1 100%", "0 0 90px"], + selectValue: selectOptionsMonths[0].value, + }, -Rtl.argTypes = { - selectValue: { - options: selectOptionsMonths.map(opt => opt.value), - control: { - type: "select", + argTypes: { + selectValue: { + options: selectOptionsMonths.map(opt => opt.value), + control: { + type: "select", + }, }, }, };