diff --git a/site/src/components/Slider/Slider.stories.tsx b/site/src/components/Slider/Slider.stories.tsx new file mode 100644 index 0000000000000..480e12c090382 --- /dev/null +++ b/site/src/components/Slider/Slider.stories.tsx @@ -0,0 +1,57 @@ +import type { Meta, StoryObj } from "@storybook/react"; +import React from "react"; +import { Slider } from "./Slider"; + +const meta: Meta = { + title: "components/Slider", + component: Slider, + args: {}, + argTypes: { + value: { + control: "number", + description: "The controlled value of the slider", + }, + defaultValue: { + control: "number", + description: "The default value when initially rendered", + }, + disabled: { + control: "boolean", + description: + "When true, prevents the user from interacting with the slider", + }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Default: Story = {}; + +export const Controlled: Story = { + render: (args) => { + const [value, setValue] = React.useState(50); + return ( + setValue(v)} /> + ); + }, + args: { value: [50], min: 0, max: 100, step: 1 }, +}; + +export const Uncontrolled: Story = { + args: { defaultValue: [30], min: 0, max: 100, step: 1 }, +}; + +export const Disabled: Story = { + args: { defaultValue: [40], disabled: true }, +}; + +export const MultipleThumbs: Story = { + args: { + defaultValue: [20, 80], + min: 0, + max: 100, + step: 5, + minStepsBetweenThumbs: 1, + }, +}; diff --git a/site/src/components/Slider/Slider.tsx b/site/src/components/Slider/Slider.tsx new file mode 100644 index 0000000000000..4fdd21353e963 --- /dev/null +++ b/site/src/components/Slider/Slider.tsx @@ -0,0 +1,39 @@ +/** + * Copied from shadc/ui on 04/16/2025 + * @see {@link https://ui.shadcn.com/docs/components/slider} + */ +import * as SliderPrimitive from "@radix-ui/react-slider"; +import * as React from "react"; + +import { cn } from "utils/cn"; + +export const Slider = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef +>(({ className, ...props }, ref) => ( + + + + + + + +));