Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Slider component #810

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@lyyti/design-system",
"description": "Lyyti Design System",
"homepage": "https://lyytioy.github.io/lyyti-design-system",
"version": "4.0.2",
"version": "4.1.0",
"engines": {
"node": "^18",
"npm": "^9"
Expand Down
10 changes: 10 additions & 0 deletions src/components/Slider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Slider as MuiSlider } from "@mui/material";
import { SliderProps as MuiSliderProps } from '@mui/material/Slider/Slider'

export interface SliderProps extends MuiSliderProps {}

const Slider = ({ ...props }: SliderProps) => {
return <MuiSlider {...props} />
}

export default Slider;
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export { default as TableFooter } from '@mui/material/TableFooter';
export { default as TableRow } from '@mui/material/TableRow';
export { default as ToggleButtonGroup } from './components/ToggleButtonGroup';
export type { ToggleButtonOption } from './components/ToggleButtonGroup';
export { default as Slider } from './components/Slider';
export { createFilterOptions } from '@mui/material/useAutocomplete';
export { useTheme } from '@mui/system';
export type { SxProps } from '@mui/material';
Expand Down
78 changes: 78 additions & 0 deletions stories/Inputs/Slider.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { StoryFn, Meta } from '@storybook/react';
import { Box } from '../../src';
import Slider, { SliderProps } from '../../src/components/Slider'

const meta: Meta<typeof Slider> = {
title: 'Components/Inputs/Slider',
component: Slider,
argTypes: {
min: {
control: { type: 'number'},
table: { defaultValue: { summary: 0 } },
description: 'Minimal value that can be set',
},
max: {
control: { type: 'number'},
table: { defaultValue: { summary: 100 } },
description: 'Maximum value that can be set',
},
step: {
control: { type: 'number'},
table: { defaultValue: { summary: 1 } },
description: 'Each step value the slider will take',
},
valueLabelDisplay: {
control: { options: ['on', 'auto', 'off'] },
table: { defaultValue: { summary: 'off' } },
description: 'Controls labels visibility',
},
marks: {
control: { type: 'object'},
table: { defaultValue: { summary: false } },
description: 'Marks to display on the slider. {value: number, label: string}[] or boolean',
},
},
};

const Template: StoryFn<SliderProps> = (args) => (
<Box sx={{ width: 300 }}>
<Slider {...args} />
</Box>);

export const Default = Template.bind({});
Default.args = {
min: 0,
max: 100,
step: 1,
valueLabelDisplay: 'off',
marks: [],
};

export const Percentage = Template.bind({});
Percentage.args = {
min: 0,
max: 100,
step: 1,
valueLabelDisplay: 'auto',
marks: [{ value: 0, label: '0%' }, { value: 100, label: '100%'}]
};

export const VisibleValue = Template.bind({});
VisibleValue.args = {
min: 0,
max: 100,
step: 1,
marks: [],
valueLabelDisplay: 'on',
};

export const Range = Template.bind({});
Range.args = {
min: 0,
max: 100,
step: 1,
marks: [],
value: [20, 60],
};

export default meta;