import { rocketLaunch, screwdriverWrench, truck } from "@simplybusiness/icons"; import type { Meta, StoryObj } from "@storybook/react"; import { excludeControls } from "../../utils"; import { StoryContainer } from "../../utils/StoryContainer"; import { Divider } from "../Divider"; import { Flex } from "../Flex"; import { Icon } from "../Icon"; import { TextOrHTML } from "../TextOrHTML"; import { Radio } from "./Radio"; import type { RadioGroupProps } from "./RadioGroup"; import { RadioGroup } from "./RadioGroup"; type StoryType = StoryObj; const meta: Meta = { title: "Forms/Radio", component: RadioGroup, argTypes: { orientation: { control: { type: "radio" }, options: ["horizontal", "vertical"], }, label: { control: { type: "text" }, }, ...excludeControls( "name", "groupDisabled", "selected", "setSelected", "defaultValue", "value", "validationState", ), }, decorators: [ Story => ( ), ], }; export const Default: StoryType = { render: (args: RadioGroupProps) => ( ), args: { label: "Color", isDisabled: false, isRequired: false, errorMessage: "", orientation: "vertical", defaultValue: "blue", }, }; export const Disabled: StoryType = { render: (args: RadioGroupProps) => ( ), args: { label: "Color", isDisabled: true, isRequired: false, errorMessage: "", orientation: "vertical", }, }; export const DisabledIndividualRadios: StoryType = { render: (args: RadioGroupProps) => ( ), args: { label: "Color", isDisabled: false, isRequired: false, errorMessage: "", orientation: "vertical", }, }; export const Valid: StoryType = { render: (args: RadioGroupProps) => ( ), args: { label: "Color", isDisabled: false, isRequired: false, errorMessage: "", isInvalid: false, orientation: "vertical", }, }; export const Invalid: StoryType = { render: (args: RadioGroupProps) => ( ), args: { label: "Color", isDisabled: false, isRequired: false, errorMessage: "Please select a color", isInvalid: true, orientation: "vertical", }, }; export const WithIconViaChildren: StoryType = { render: (args: RadioGroupProps) => ( Truck Rocket Screwdriver ), }; export const ComplexLabel: StoryType = { render: (args: RadioGroupProps) => (
To pay today
$1265.00
To pay today
$316.25
10 monthly payments of
$94.88
Total
$1265.00
), args: { label: "Payment Options", isDisabled: false, isRequired: false, errorMessage: "", orientation: "vertical", }, }; export const HorizontalLayout: StoryType = { render: (args: RadioGroupProps) => ( ), args: { label: "Color", isDisabled: false, isRequired: false, errorMessage: "", orientation: "horizontal", }, }; export const AutoStack: StoryType = { render: () => (

With autoStack enabled, RadioGroup automatically changes from horizontal to vertical orientation when any radio label overflows. Resize the container to see it in action.

), }; export const WithHTMLLabels: StoryType = { render: (args: RadioGroupProps) => ( } /> } /> } /> ), args: { label: "Property type", isDisabled: false, isRequired: false, errorMessage: "", orientation: "vertical", }, parameters: { docs: { description: { story: "Radio labels can contain HTML content using the TextOrHTML component. This is useful when labels need inline formatting like bold or italic text.", }, }, }, }; export default meta;