Fix slider and switch components
This commit is contained in:
parent
f17232bc5e
commit
f9ba98ca82
4 changed files with 29 additions and 17 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
.Slider {
|
.slider {
|
||||||
position: relative;
|
position: relative;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
width: $unit-20x;
|
width: $unit-20x;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
|
||||||
.SliderTrack {
|
.track {
|
||||||
background-color: var(--button-bg);
|
background-color: var(--button-bg);
|
||||||
position: relative;
|
position: relative;
|
||||||
flex-grow: 1;
|
flex-grow: 1;
|
||||||
|
|
@ -16,14 +16,14 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.SliderRange {
|
.range {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
background-color: var(--accent-blue);
|
background-color: var(--accent-blue);
|
||||||
border-radius: 9999px;
|
border-radius: 9999px;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.SliderThumb {
|
.thumb {
|
||||||
display: block;
|
display: block;
|
||||||
width: 20px;
|
width: 20px;
|
||||||
height: 20px;
|
height: 20px;
|
||||||
|
|
|
||||||
|
|
@ -9,19 +9,20 @@ interface Props {}
|
||||||
|
|
||||||
const Slider = React.forwardRef<HTMLDivElement, Props & SliderProps>(
|
const Slider = React.forwardRef<HTMLDivElement, Props & SliderProps>(
|
||||||
(props, forwardedRef) => {
|
(props, forwardedRef) => {
|
||||||
const value = props.value || props.defaultValue
|
const classes = classNames(
|
||||||
|
{
|
||||||
|
[styles.slider]: true,
|
||||||
|
},
|
||||||
|
props.className?.split(' ').map((c) => styles[c])
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SliderPrimitive.Slider
|
<SliderPrimitive.Slider {...props} className={classes} ref={forwardedRef}>
|
||||||
{...props}
|
<SliderPrimitive.Track className={styles.track}>
|
||||||
className={classNames({ Slider: true }, props.className)}
|
<SliderPrimitive.Range className={styles.range} />
|
||||||
ref={forwardedRef}
|
|
||||||
>
|
|
||||||
<SliderPrimitive.Track className="SliderTrack">
|
|
||||||
<SliderPrimitive.Range className="SliderRange" />
|
|
||||||
</SliderPrimitive.Track>
|
</SliderPrimitive.Track>
|
||||||
|
|
||||||
<SliderPrimitive.Thumb className="SliderThumb" />
|
<SliderPrimitive.Thumb className={styles.thumb} />
|
||||||
</SliderPrimitive.Slider>
|
</SliderPrimitive.Slider>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.Switch {
|
.switch {
|
||||||
$height: 34px;
|
$height: 34px;
|
||||||
background: $grey-70;
|
background: $grey-70;
|
||||||
border-radius: calc($height / 2);
|
border-radius: calc($height / 2);
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.SwitchThumb {
|
.thumb {
|
||||||
background: $grey-100;
|
background: $grey-100;
|
||||||
border-radius: 13px;
|
border-radius: 13px;
|
||||||
display: block;
|
display: block;
|
||||||
|
|
|
||||||
|
|
@ -25,8 +25,19 @@ const Switch = (props: Props) => {
|
||||||
value,
|
value,
|
||||||
} = props
|
} = props
|
||||||
|
|
||||||
const mainClasses = classNames({ Switch: true }, className)
|
const mainClasses = classNames(
|
||||||
const thumbClasses = classNames({ SwitchThumb: true }, thumbClass)
|
{
|
||||||
|
[styles.switch]: true,
|
||||||
|
},
|
||||||
|
className?.split(' ').map((c) => styles[c])
|
||||||
|
)
|
||||||
|
|
||||||
|
const thumbClasses = classNames(
|
||||||
|
{
|
||||||
|
[styles.thumb]: true,
|
||||||
|
},
|
||||||
|
thumbClass?.split(' ').map((c) => styles[c])
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RadixSwitch.Root
|
<RadixSwitch.Root
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue