import React from "react"; import Switch from "../../app/components/controls/Switch"; export default { title: "Components/Controls/Switch", component: Switch, parameters: { layout: "centered", }, argTypes: { propSwitch: { control: "boolean", description: "Whether the switch is checked (on) or not (off) (Figma prop)", }, state: { control: "select", options: ["default", "focus"], description: "Visual state of the switch", }, text: { control: "text", description: "Label text displayed next to the switch (Figma prop)", }, onChange: { action: "changed", description: "Callback fired when the switch is toggled", }, onFocus: { action: "focused", description: "Callback fired when the switch receives focus", }, onBlur: { action: "blurred", description: "Callback fired when the switch loses focus", }, }, }; const Template = (args) => ; export const Default = Template.bind({}); Default.args = { propSwitch: false, text: "Switch label", }; export const Checked = Template.bind({}); Checked.args = { propSwitch: true, text: "Switch label", }; export const Focus = Template.bind({}); Focus.args = { propSwitch: false, state: "focus", text: "Switch label", }; export const FocusChecked = Template.bind({}); FocusChecked.args = { propSwitch: true, state: "focus", text: "Switch label", }; export const States = () => (

Switch States

); export const Interactive = () => { const [propSwitch, setPropSwitch] = React.useState(false); const [state, setState] = React.useState("default"); return (

Interactive Switch

setPropSwitch(!propSwitch)} text="Enable notifications" />

Controls

); }; export const WithText = () => (

Switch with Different Labels

);