Skip to content

Commit

Permalink
Added story with customized slider
Browse files Browse the repository at this point in the history
  • Loading branch information
ValentinaKozlova committed Jan 20, 2025
1 parent 8975b05 commit df41a58
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as React from 'react';
import { useId, Label, Slider, makeStyles, sliderCSSVars, tokens } from '@fluentui/react-components';

const { sliderProgressColorVar, sliderRailColorVar, sliderThumbColorVar, sliderThumbSizeVar } = sliderCSSVars;

const useStyles = makeStyles({
enabled: {
[sliderProgressColorVar]: '#ff0764',
[sliderRailColorVar]: tokens.colorNeutralForeground1,
[sliderThumbColorVar]: '#ff0764',
':hover': {
[sliderThumbColorVar]: '#d60d58',
[sliderProgressColorVar]: '#d60d58',
':active': {
[sliderThumbColorVar]: '#b91150',
[sliderProgressColorVar]: '#b91150',
},
},
},
thumb: {
[sliderThumbSizeVar]: '16px',
boxShadow: `0 0 0 calc(var(${sliderThumbSizeVar}) * .2) ${tokens.colorTransparentBackground} inset`,
'::before': {
content: 'unset',
},
},
});

export const Customized = () => {
const id = useId();
const styles = useStyles();

return (
<>
<Label htmlFor={id}>Customized slider</Label>
<Slider className={styles.enabled} thumb={{ className: styles.thumb }} defaultValue={20} size="small" id={id} />
</>
);
};

Customized.parameters = {
docs: {
description: {
story: 'Customized slider using its variables',
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export { Step } from './SliderStep.stories';
export { MinMax } from './SliderMinMax.stories';
export { Vertical } from './SliderVertical.stories';
export { Disabled } from './SliderDisabled.stories';
export { Customized } from './SliderCustomized.stories';

export default {
title: 'Components/Slider',
Expand Down

0 comments on commit df41a58

Please sign in to comment.