import React from "react";
import ToggleGroup from "../../app/components/controls/ToggleGroup";
import {
STATE_OPTIONS,
TOGGLE_GROUP_POSITION_OPTIONS,
} from "../../lib/propNormalization";
export default {
title: "Components/Controls/ToggleGroup",
component: ToggleGroup,
parameters: {
layout: "centered",
},
argTypes: {
position: {
control: { type: "select" },
options: [...TOGGLE_GROUP_POSITION_OPTIONS],
},
state: {
control: { type: "select" },
options: [...STATE_OPTIONS],
},
showText: {
control: { type: "boolean" },
},
},
};
const Template = (args) => Toggle Item;
export const Default = {
args: {
position: "left",
state: "default",
showText: true,
},
render: Template,
};
export const Middle = {
args: {
position: "middle",
state: "default",
showText: true,
},
render: Template,
};
export const Right = {
args: {
position: "right",
state: "default",
showText: true,
},
render: Template,
};
export const States = () => (
Toggle Group States
Default
Hover
Focus
Selected
);
export const Positions = () => (
Toggle Group Positions
Left
Middle
Middle
Right
);
export const WithText = {
args: {
position: "left",
state: "default",
showText: true,
children: "Active Deals",
},
render: Template,
};
export const WithoutText = {
args: {
position: "left",
state: "default",
showText: false,
children: "☰",
},
render: Template,
};
export const WithIcons = () => (
Toggle Group with Icons
☰
☰
☰
);
export const Interactive = () => {
const [selectedPosition, setSelectedPosition] = React.useState("left");
const [state, setState] = React.useState("default");
const [showText, setShowText] = React.useState(true);
return (
Interactive Toggle Group
setSelectedPosition("left")}
ariaLabel={!showText ? "Active Deals" : undefined}
>
{showText ? "Active Deals" : "☰"}
setSelectedPosition("middle")}
ariaLabel={!showText ? "Inactive Deals" : undefined}
>
{showText ? "Inactive Deals" : "☰"}
setSelectedPosition("right")}
ariaLabel={!showText ? "Pending Deals" : undefined}
>
{showText ? "Pending Deals" : "☰"}
);
};