import React, { useState } from 'react' import { type Meta, type StoryObj } from '@storybook/react-vite' import { DocsTemplate } from '../../../.storybook' import SliderComponent from './Slider' const meta: Meta = { title: 'Components/FormComponents/Slider', component: SliderComponent, parameters: { design: { type: 'figma', url: 'https://www.figma.com/design/RvhKD82948FMQnh5MyCi0o/Web-Design-System?node-id=777-6437&t=9R4mlUY42yEaNlLp-4', }, docs: { page: () => ( The Slider component is a form element used to keep track of a single numerical value within a defined range. It allows users to slide a handle along a track to select a specific numeric value. Sliders are commonly used for settings, input ranges, and other scenarios where precise numeric input is required. } infoBullets={[ Implement the Slider component in forms or settings sections where users need to choose a numeric value from a defined range. , Ensure the Slider component is labeled clearly and concisely to aid user comprehension and efficient selection. , If needed, include a tooltip to provide additional context or description for the Slider. , ]} /> ), }, }, } export default meta type Story = StoryObj const Template: Story = { render: function Render(args) { const [threshold, setThreshold] = useState(args.value) const updateThreshold = (value: number) => { setThreshold(value) } return ( ) }, } export const Basic: Story = { ...Template, args: { value: 32, label: 'Basic Slider', }, } export const Required: Story = { ...Template, args: { value: 32, label: 'Basic Slider', required: true, }, } export const Tooltip: Story = { ...Template, args: { value: 32, label: 'Slider Tooltip', tooltip: { tooltipContent: 'This is the slider tooltip', }, }, } export const LabelTooltip: Story = { ...Template, args: { value: 32, label: 'Label Tooltip', labelTooltip: { tooltipContent: 'This is the label tooltip', }, }, } export const RightLabel: Story = { ...Template, args: { value: 32, label: 'Label', rightLabel: 'Right Label', }, } export const Steps: Story = { ...Template, args: { value: 25, label: 'Slider With Steps', step: 25, }, } export const LargeNumber: Story = { ...Template, args: { value: 1500000, label: 'Large Number', min: 1000000, max: 2000000, step: 100000, }, } export const Percentage: Story = { ...Template, args: { value: 32, label: 'Percentage', suffix: '%', }, } export const Currency: Story = { ...Template, args: { value: 32, label: 'Currency', prefix: '$', }, } export const Debounce: Story = { render: function Render(args) { const [value, setValue] = useState(args.value) return ( <>
There is a delay of {args.debounce}ms after each movement of the slider
Debounced Value: {value}
) }, args: { value: 5, label: 'Debounce', debounce: 500, }, }