-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
10c4c40
commit d906dba
Showing
4 changed files
with
142 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Meta, StoryObj } from '@storybook/react'; | ||
|
||
import Slider from './Slider'; | ||
|
||
const meta: Meta<typeof Slider> = { | ||
title: 'Components/Slider', | ||
component: Slider, | ||
tags: ['autodocs'], | ||
parameters: { | ||
layout: 'centered', | ||
}, | ||
decorators: [ | ||
Story => ( | ||
<div | ||
style={{ | ||
width: '200px', | ||
}} | ||
> | ||
<Story /> | ||
</div> | ||
), | ||
], | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof Slider>; | ||
|
||
export const Default: Story = { | ||
args: { | ||
label: 'Volume', | ||
min: 0, | ||
max: 100, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React from 'react'; | ||
|
||
type SliderProps = { | ||
/** | ||
* label description for the slider | ||
*/ | ||
label: string; | ||
/** | ||
* the minimum value for the slider | ||
*/ | ||
min: number; | ||
/** | ||
* the maximum value for the slider | ||
*/ | ||
max: number; | ||
/** | ||
* the current value of the slider | ||
*/ | ||
value: number; | ||
/** | ||
* handler for the slider value change | ||
*/ | ||
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void; | ||
}; | ||
|
||
const Slider = (props: SliderProps) => { | ||
const { label, min, max, value, onChange } = props; | ||
|
||
const id = React.useId(); | ||
|
||
return ( | ||
<div className="flex flex-col items-center gap-2"> | ||
<label htmlFor={id} className="text-base font-medium "> | ||
{label} | ||
</label> | ||
<input | ||
type="range" | ||
id={id} | ||
min={min} | ||
max={max} | ||
value={value} | ||
onChange={onChange} | ||
className="slider" | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Slider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from './Slider'; |