fa5a190416
CI Pipeline / test (20) (pull_request) Successful in 2m30s
CI Pipeline / test (18) (pull_request) Successful in 3m51s
CI Pipeline / e2e (firefox) (pull_request) Successful in 3m22s
CI Pipeline / e2e (webkit) (pull_request) Successful in 3m45s
CI Pipeline / e2e (chromium) (pull_request) Successful in 11m49s
CI Pipeline / visual-regression (pull_request) Successful in 6m48s
CI Pipeline / storybook (pull_request) Successful in 1m35s
CI Pipeline / lint (pull_request) Successful in 1m12s
CI Pipeline / build (pull_request) Successful in 1m54s
CI Pipeline / performance (pull_request) Successful in 4m6s
159 lines
3.9 KiB
JavaScript
159 lines
3.9 KiB
JavaScript
import React from "react";
|
|
import RadioButton from "../app/components/RadioButton";
|
|
import {
|
|
DefaultInteraction,
|
|
CheckedInteraction,
|
|
StandardInteraction,
|
|
InverseInteraction,
|
|
KeyboardInteraction,
|
|
AccessibilityInteraction,
|
|
FormIntegration,
|
|
} from "../tests/storybook/RadioButton.interactions.test";
|
|
|
|
const meta = {
|
|
title: "Forms/RadioButton",
|
|
component: RadioButton,
|
|
parameters: {
|
|
layout: "centered",
|
|
backgrounds: {
|
|
default: "dark",
|
|
values: [{ name: "dark", value: "black" }],
|
|
},
|
|
},
|
|
tags: ["autodocs"],
|
|
argTypes: {
|
|
checked: { control: "boolean" },
|
|
mode: {
|
|
control: { type: "select" },
|
|
options: ["standard", "inverse"],
|
|
},
|
|
state: {
|
|
control: { type: "select" },
|
|
options: ["default", "hover", "focus"],
|
|
},
|
|
label: { control: "text" },
|
|
},
|
|
args: {
|
|
checked: false,
|
|
mode: "standard",
|
|
state: "default",
|
|
label: "Radio Button Label",
|
|
},
|
|
};
|
|
|
|
export default meta;
|
|
|
|
export const Default = {
|
|
args: {
|
|
checked: false,
|
|
mode: "standard",
|
|
state: "default",
|
|
label: "Default radio button",
|
|
},
|
|
play: DefaultInteraction.play,
|
|
render: (args) => {
|
|
const [checked, setChecked] = React.useState(args.checked);
|
|
return (
|
|
<RadioButton
|
|
{...args}
|
|
checked={checked}
|
|
onChange={({ checked: newChecked }) => setChecked(newChecked)}
|
|
/>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const Checked = {
|
|
args: {
|
|
checked: true,
|
|
mode: "standard",
|
|
state: "default",
|
|
label: "Checked radio button",
|
|
},
|
|
play: CheckedInteraction.play,
|
|
render: (args) => {
|
|
const [checked, setChecked] = React.useState(args.checked);
|
|
return (
|
|
<RadioButton
|
|
{...args}
|
|
checked={checked}
|
|
onChange={({ checked: newChecked }) => setChecked(newChecked)}
|
|
/>
|
|
);
|
|
},
|
|
};
|
|
|
|
export const Standard = {
|
|
render: () => {
|
|
const [selectedValue, setSelectedValue] = React.useState("checked");
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<div className="space-y-2">
|
|
<h3 className="text-white font-medium">Standard Mode</h3>
|
|
<div className="flex flex-col gap-2">
|
|
<RadioButton
|
|
label="Unchecked"
|
|
checked={selectedValue === "unchecked"}
|
|
name="standard-example"
|
|
value="unchecked"
|
|
mode="standard"
|
|
onChange={({ checked }) => {
|
|
if (checked) setSelectedValue("unchecked");
|
|
}}
|
|
/>
|
|
<RadioButton
|
|
label="Checked"
|
|
checked={selectedValue === "checked"}
|
|
name="standard-example"
|
|
value="checked"
|
|
mode="standard"
|
|
onChange={({ checked }) => {
|
|
if (checked) setSelectedValue("checked");
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
},
|
|
play: StandardInteraction.play,
|
|
};
|
|
|
|
export const Inverse = {
|
|
render: () => {
|
|
const [selectedValue, setSelectedValue] = React.useState("checked");
|
|
|
|
return (
|
|
<div className="space-y-4">
|
|
<div className="space-y-2">
|
|
<h3 className="text-white font-medium">Inverse Mode</h3>
|
|
<div className="flex flex-col gap-2">
|
|
<RadioButton
|
|
label="Unchecked"
|
|
checked={selectedValue === "unchecked"}
|
|
name="inverse-example"
|
|
value="unchecked"
|
|
mode="inverse"
|
|
onChange={({ checked }) => {
|
|
if (checked) setSelectedValue("unchecked");
|
|
}}
|
|
/>
|
|
<RadioButton
|
|
label="Checked"
|
|
checked={selectedValue === "checked"}
|
|
name="inverse-example"
|
|
value="checked"
|
|
mode="inverse"
|
|
onChange={({ checked }) => {
|
|
if (checked) setSelectedValue("checked");
|
|
}}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
);
|
|
},
|
|
play: InverseInteraction.play,
|
|
};
|