diff --git a/docs/app/experiments/slider-change-committed-lag.tsx b/docs/app/experiments/slider-change-committed-lag.tsx index 673b39ad78..885b3e9597 100644 --- a/docs/app/experiments/slider-change-committed-lag.tsx +++ b/docs/app/experiments/slider-change-committed-lag.tsx @@ -3,7 +3,7 @@ // to cross check whether this issue would still occur in the new API import * as React from 'react'; import { Slider } from '@base_ui/react/Slider'; -import { Styles } from './slider'; +import classes from './slider.module.css'; export default function App() { const [val1, setVal1] = React.useState(80); @@ -17,23 +17,22 @@ export default function App() { }} > setVal1(newValue as number)} onValueCommitted={(newValue) => setVal2(newValue as number)} > - - - - - + + + + +
onValueChange value: {val1}
onValueCommitted value: {val2}
- ); } diff --git a/docs/app/experiments/slider-marks.tsx b/docs/app/experiments/slider-marks.tsx index 04194347ca..3aca9f1326 100644 --- a/docs/app/experiments/slider-marks.tsx +++ b/docs/app/experiments/slider-marks.tsx @@ -1,6 +1,7 @@ 'use client'; import * as React from 'react'; import { Slider } from '@base_ui/react/Slider'; +import { useSliderContext } from '../../../packages/mui-base/src/Slider/Root/SliderContext'; const STOPS = [ { @@ -32,7 +33,7 @@ function getSliderThumbAriaValueText(value: number) { // for "inverted track", the track/rail can be styled with CSS but a prop is needed to flip the "mark active" state function MarkWithLabel(props: { index: number; value: number; label: string; inverted?: boolean }) { const { index, value, label, inverted = false } = props; - const { direction, values } = Slider.useSliderContext(); + const { direction, values } = useSliderContext(); const isRtl = direction === 'rtl'; const isFilled = inverted ? value >= values[0] : values[0] >= value; return ( diff --git a/docs/app/experiments/slider-template.tsx b/docs/app/experiments/slider-template.tsx deleted file mode 100644 index 7472d3a329..0000000000 --- a/docs/app/experiments/slider-template.tsx +++ /dev/null @@ -1,19 +0,0 @@ -'use client'; -import * as React from 'react'; -import { Slider } from '@base_ui/react/Slider'; -import { Styles } from './slider'; - -export default function App() { - return ( -
- - - - - - - - -
- ); -} diff --git a/docs/app/experiments/slider-tooltip.tsx b/docs/app/experiments/slider-tooltip.tsx index 2d8b140855..28d89d6855 100644 --- a/docs/app/experiments/slider-tooltip.tsx +++ b/docs/app/experiments/slider-tooltip.tsx @@ -3,6 +3,7 @@ import * as React from 'react'; import { useTheme } from '@mui/system'; import { Slider } from '@base_ui/react/Slider'; import { Tooltip } from '@base_ui/react/Tooltip'; +import { useSliderContext } from '../../../packages/mui-base/src/Slider/Root/SliderContext'; function useIsDarkMode() { const theme = useTheme(); @@ -73,7 +74,7 @@ export default function App() { const SliderMark = React.forwardRef(function SliderMark(props: any, ref: React.ForwardedRef) { const { index, style, ...otherProps } = props; - const { percentageValues } = Slider.useSliderContext(); + const { percentageValues } = useSliderContext(); const isFilled = percentageValues[0] >= index * 10; return ( -

Uncontrolled

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

- Controlled -

- { - setVal1(newValue as number); - }} - > - - - - - - - - - - { - setVal2(newValue as number[]); - }} - > - - - - - - - - - - - { - setVal3(newValue as number[]); - }} - > - - - - {val3.map((_val, idx) => ( - - ))} - - - - -

- With custom labels -

- - - - - - - - - - - - - - Volume Range - - - - - - - - - - - -

- Vertical -

- - - - - - - - - - - - - - - - - - - - - -

- RTL -

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Price Range - - - - - ); -} - -function Label(props: any) { - const { id: idProp, ...otherProps } = props; - const defaultId = React.useId(); - const labelId = idProp ?? defaultId; - - const { subitems } = Slider.useSliderContext(); - - const htmlFor = Array.from(subitems.values()) - .reduce((acc, item) => { - return `${acc} ${item.inputId}`; - }, '') - .trim(); - - return