UNPKG

gov-gui

Version:

Gov UI Component Library Typscript Build

160 lines (159 loc) 6.62 kB
import { html } from "lit-html"; import "../../global/animate.min.css"; /** * Checkboxes allow users to select one or more options from a set. * The `gov-checkbox` component can be customized with labels, disabled state, and checked state. */ export default { title: 'Components/Checkbox', tags: ['autodocs'], parameters: { actions: { handles: ['valueChanged'], // Track change actions }, }, argTypes: { label: { control: 'text', description: 'The label text displayed next to the checkbox.', table: { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Attributes', }, }, checked: { control: 'boolean', description: 'Sets the initial checked state of the checkbox. Is also used to to extract the checked value e.g: comp.checked.', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, category: 'Attributes', }, }, disabled: { control: 'boolean', description: 'Disables the checkbox, preventing user interaction.', table: { type: { summary: 'boolean' }, defaultValue: { summary: 'false' }, category: 'Attributes', }, }, required: { control: 'boolean', description: 'Dictates if the property is required.', table: { type: { summary: 'boolean' }, defaultValue: { summary: false }, category: 'Attributes', }, }, requiredErrorMessage: { control: 'text', description: 'Text that will be displayed if is required.', table: { type: { summary: 'string' }, defaultValue: { summary: 'This field is required' }, 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', }, }, valueChanged: { action: 'valueChanged', description: 'Event emitted when radio button is clicked.', table: { type: { summary: 'void' }, defaultValue: { summary: () => { } }, category: 'Events', }, }, getValue: { control: 'getValue', description: 'Method to extract the component\'s value, e.g: comp.getValue()', table: { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Interaction', }, }, validate: { control: 'validate', description: 'Method to validate the component\'s value, e.g: comp.validate()', table: { type: { summary: 'string' }, defaultValue: { summary: '' }, category: 'Interaction', }, }, }, }; const Template = (args) => html ` <gov-checkbox label="${args.label}" ?checked="${args.checked}" ?disabled="${args.disabled}" ?required="${args.required}" @valueChanged="${args.valueChanged}" animation-delay="${args.animationDelay}" animation="${args.animation}" animation-speed="${args.animationSpeed}" ></gov-checkbox> `; export const Checkbox = Template.bind({}); Checkbox.args = { label: 'I agree to the terms and conditions', // Example label checked: true, // Default unchecked state disabled: false, // Checkbox is enabled by default required: false, // Checkbox is required by default animation: '', animationDelay: '', animationSpeed: '', }; //# sourceMappingURL=gov-checkbox.stories.js.map