gov-gui
Version:
Gov UI Component Library Typscript Build
150 lines (149 loc) • 5.95 kB
JavaScript
import { fn } from "@storybook/test";
import { html } from "lit-html";
import "../../global/animate.min.css";
/**
* This is a user interface component that allows users to switch between two states: "on" and "off."
* It resembles a physical switch and is used to enable or disable a particular feature or setting.
*/
export default {
title: 'Components/Switcher', // Added the category 'Inputs'
tags: ['autodocs'],
parameters: {
actions: {
handles: { toggled: fn() },
}
},
argTypes: {
isOn: {
control: 'boolean',
description: 'Defines whether the switch is initially on or off',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: false },
category: 'Attributes',
},
},
showLabel: {
control: 'boolean',
description: 'Defines if the switch displays ON/OFF text',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: false },
category: 'Attributes',
},
},
hasIcons: {
control: 'boolean',
description: 'Defines if the switch displays icons',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: false },
category: 'Attributes',
},
},
disabled: {
control: 'boolean',
description: 'Disables the switch if set to true',
table: {
type: { summary: 'boolean' },
defaultValue: { summary: false },
category: 'Attributes',
},
},
size: {
control: 'select',
options: ['small', 'medium'],
description: 'Sets the size of the switch',
table: {
type: { summary: 'string' },
defaultValue: { summary: 'small' },
category: 'Attributes',
},
},
animation: {
control: 'select',
options: ["",
"bounce", "flash", "pulse", "rubberBand", "shakeX", "shakeY", "headShake", "swing", "tada", "wobble", "jello", "heartBeat",
"backInDown", "backInLeft", "backInRight", "backInUp",
"backOutDown", "backOutLeft", "backOutRight", "backOutUp",
"bounceIn", "bounceInDown", "bounceInLeft", "bounceInRight", "bounceInUp",
"bounceOut", "bounceOutDown", "bounceOutLeft", "bounceOutRight", "bounceOutUp",
"fadeIn", "fadeInDown", "fadeInDownBig", "fadeInLeft", "fadeInLeftBig", "fadeInRight", "fadeInRightBig", "fadeInUp", "fadeInUpBig", "fadeInTopLeft", "fadeInTopRight", "fadeInBottomLeft", "fadeInBottomRight",
"fadeOut", "fadeOutDown", "fadeOutDownBig", "fadeOutLeft", "fadeOutLeftBig", "fadeOutRight", "fadeOutRightBig", "fadeOutUp", "fadeOutUpBig", "fadeOutTopLeft", "fadeOutTopRight", "fadeOutBottomRight", "fadeOutBottomLeft",
"flip", "flipInX", "flipInY", "flipOutX", "flipOutY",
"lightSpeedInRight", "lightSpeedInLeft", "lightSpeedOutRight", "lightSpeedOutLeft",
"rotateIn", "rotateInDownLeft", "rotateInDownRight", "rotateInUpLeft", "rotateInUpRight",
"rotateOut", "rotateOutDownLeft", "rotateOutDownRight", "rotateOutUpLeft", "rotateOutUpRight",
"hinge", "jackInTheBox", "rollIn", "rollOut",
"zoomIn", "zoomInDown", "zoomInLeft", "zoomInRight", "zoomInUp",
"zoomOut", "zoomOutDown", "zoomOutLeft", "zoomOutRight", "zoomOutUp",
"slideInDown", "slideInLeft", "slideInRight", "slideInUp",
"slideOutDown", "slideOutLeft", "slideOutRight", "slideOutUp"
],
description: 'Selects the animation effect to apply to the component.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Animations',
},
},
animationDelay: {
control: 'select',
options: ["2s", "3s", "4s", "5s"],
description: 'Sets the delay before the animation begins (in seconds).',
table: {
type: { summary: 'string' },
defaultValue: { summary: '2s' },
category: 'Animations',
},
},
animationSpeed: {
control: 'select',
options: ["slow", "slower", "fast", "faster"],
description: 'Controls how quickly the animation plays.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Animations',
},
},
toggled: {
control: 'event',
action: 'toggled',
description: 'Event emitted when the toggled.',
table: {
type: { summary: 'string' },
defaultValue: { summary: () => { } },
category: 'Events',
},
},
},
};
const Template = (args) => html `
<gov-switcher
is-on="${args.isOn}"
show-label="${args.showLabel}"
has-icons="${args.hasIcons}"
?disabled="${args.disabled}"
size="${args.size}"
animation-delay="${args.animationDelay}"
animation="${args.animation}"
animation-speed="${args.animationSpeed}"
@toggled="${args.toggled}"
>
<span slot="on-icon">🌞</span>
<span slot="off-icon">🌚</span>
</gov-switcher>
`;
export const Switcher = Template.bind({});
Switcher.args = {
isOn: true,
showLabel: false,
hasIcons: false,
disabled: false,
size: 'small',
animation: '',
animationDelay: '',
animationSpeed: '',
};
//# sourceMappingURL=gov-switcher.stories.js.map