gov-gui
Version:
Gov UI Component Library Typscript Build
146 lines (145 loc) • 5.82 kB
JavaScript
import { html } from "lit-html";
import "../../global/animate.min.css";
/**
* A Slider is a UI component that allows users to select a value or range of values
* by dragging a handle along a track.
* It’s commonly used for settings like volume control, price ranges,
* or any scenario where users need to input a value within a defined range.
*/
export default {
title: 'Components/Slider',
tags: ['autodocs'],
parameters: {
actions: {
handles: ['sliderChange'], // Track slider value changes
},
},
argTypes: {
min: {
control: 'number',
description: 'The minimum value of the slider range.',
table: {
type: { summary: 'number' },
defaultValue: { summary: 0 },
category: 'Attributes',
},
},
max: {
control: 'number',
description: 'The maximum value of the slider range.',
table: {
type: { summary: 'number' },
defaultValue: { summary: 100 },
category: 'Attributes',
},
},
step: {
control: 'number',
description: 'The increment value between each valid slider position.',
table: {
type: { summary: 'number' },
defaultValue: { summary: 1 },
category: 'Attributes',
},
},
label: {
control: 'text',
description: 'The label text displayed above the slider.',
table: {
type: { summary: 'string' },
defaultValue: { summary: '' },
category: 'Attributes',
},
},
value: {
control: 'number',
description: 'The value of the slider.',
table: {
type: { summary: 'number' },
defaultValue: { summary: 50 },
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',
},
},
sliderChange: {
action: 'sliderChange',
description: 'Event emitted when the slider value changes. Returns the new numeric value.',
table: {
type: { summary: 'CustomEvent<number>' },
defaultValue: { summary: undefined },
category: 'Events',
},
},
},
};
const Template = (args) => html `
<gov-slider
min="${args.min}"
max="${args.max}"
step="${args.step}"
label="${args.label}"
value="${args.value}"
="${args.sliderChange}"
animation-delay="${args.animationDelay}"
animation="${args.animation}"
animation-speed="${args.animationSpeed}"
></gov-slider>
`;
export const Slider = Template.bind({});
Slider.args = {
min: 0,
max: 100,
step: 1,
label: 'Select a value',
value: 50,
animation: '',
animationDelay: '',
animationSpeed: '',
};
//# sourceMappingURL=gov-slider.stories.js.map