Skip to content

Commit

Permalink
Fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mj12albert committed May 20, 2024
1 parent 62d1ee7 commit ff4cf43
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 26 deletions.
2 changes: 1 addition & 1 deletion docs/data/base/components/slider/slider.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
productId: base-ui
title: React Slider component and hook
components: Slider
components: Slider, SliderRoot, SliderOutput, SliderThumb, SliderTrack
hooks: useSlider
githubLabel: 'component: slider'
waiAria: https://www.w3.org/WAI/ARIA/apg/patterns/slider-multithumb/
Expand Down
17 changes: 16 additions & 1 deletion docs/pages/experiments/slider-label.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,21 @@ import { valueToPercent } from '@base_ui/react/Slider2/utils';
import { useSliderContext } from '@base_ui/react/Slider2';
import { useId } from '@base_ui/react/utils/useId';

const axisProps = {
horizontal: {
offset: (percent: number) => ({ left: `${percent}%` }),
leap: (percent: number) => ({ width: `${percent}%` }),
},
'horizontal-reverse': {
offset: (percent: number) => ({ right: `${percent}%` }),
leap: (percent: number) => ({ width: `${percent}%` }),
},
vertical: {
offset: (percent: number) => ({ bottom: `${percent}%` }),
leap: (percent: number) => ({ height: `${percent}%` }),
},
};

function TrackFillSingleThumb(props: any) {
const { value: values, min, max } = useSliderContext('Track');
const value = values[0];
Expand All @@ -22,7 +37,7 @@ function TrackFillSingleThumb(props: any) {
}

function TrackFillRange(props: any) {
const { axis, axisProps, min, max, value: values } = useSliderContext('Track');
const { axis, min, max, value: values } = useSliderContext('Track');
const { style, ...otherProps } = props;

const trackOffset = valueToPercent(values[0], min, max);
Expand Down
17 changes: 16 additions & 1 deletion docs/pages/experiments/slider-vertical.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@ import * as Slider from '@base_ui/react/Slider2';
import { valueToPercent } from '@base_ui/react/Slider2/utils';
import { useSliderContext } from '@base_ui/react/Slider2';

const axisProps = {
horizontal: {
offset: (percent: number) => ({ left: `${percent}%` }),
leap: (percent: number) => ({ width: `${percent}%` }),
},
'horizontal-reverse': {
offset: (percent: number) => ({ right: `${percent}%` }),
leap: (percent: number) => ({ width: `${percent}%` }),
},
vertical: {
offset: (percent: number) => ({ bottom: `${percent}%` }),
leap: (percent: number) => ({ height: `${percent}%` }),
},
};

function TrackFillSingleThumb(props: any) {
const { value: values, min, max, disabled } = useSliderContext('Track');
const value = values[0];
Expand All @@ -22,7 +37,7 @@ function TrackFillSingleThumb(props: any) {
}

function TrackFillRange(props: any) {
const { axis, axisProps, disabled, min, max, value: values } = useSliderContext('Track');
const { axis, disabled, min, max, value: values } = useSliderContext('Track');
const { style, ...otherProps } = props;

const trackOffset = valueToPercent(values[0], min, max);
Expand Down
1 change: 0 additions & 1 deletion packages/mui-base/src/Slider2/Root/SliderProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ SliderProvider.propTypes /* remove-proptypes */ = {
active: PropTypes.number.isRequired,
'aria-labelledby': PropTypes.string,
axis: PropTypes.oneOf(['horizontal-reverse', 'horizontal', 'vertical']).isRequired,
axisProps: PropTypes /* @typescript-to-proptypes-ignore */.object,
changeValue: PropTypes.func.isRequired,
compoundComponentContextValue: PropTypes.shape({
getItemIndex: PropTypes.func.isRequired,
Expand Down
4 changes: 0 additions & 4 deletions packages/mui-base/src/Slider2/Root/SliderRoot.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,10 +180,6 @@ export interface UseSliderReturnValue {
* The orientation of the slider.
*/
axis: Axis;
/**
* Returns the `offset` and `leap` methods to calculate the positioning styles based on the slider axis.
*/
axisProps?: { [key in Axis]: AxisProps<key> };
changeValue: (
valueInput: number,
index: number,
Expand Down
18 changes: 0 additions & 18 deletions packages/mui-base/src/Slider2/Root/useSliderRoot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,23 +111,6 @@ export function trackFinger(
};
}

// TODO: keep this here if we provide "Track Fill" component(s)
// if not move to Thumb and can probably remove leap/trackLeap too
const axisProps = {
horizontal: {
offset: (percent: number) => ({ left: `${percent}%` }),
leap: (percent: number) => ({ width: `${percent}%` }),
},
'horizontal-reverse': {
offset: (percent: number) => ({ right: `${percent}%` }),
leap: (percent: number) => ({ width: `${percent}%` }),
},
vertical: {
offset: (percent: number) => ({ bottom: `${percent}%` }),
leap: (percent: number) => ({ height: `${percent}%` }),
},
};

export const Identity = (x: any) => x;

function useSliderRoot(parameters: UseSliderParameters): UseSliderReturnValue {
Expand Down Expand Up @@ -388,7 +371,6 @@ function useSliderRoot(parameters: UseSliderParameters): UseSliderReturnValue {
active,
'aria-labelledby': ariaLabelledby,
axis,
axisProps,
changeValue,
compoundComponentContextValue,
dragging,
Expand Down

0 comments on commit ff4cf43

Please sign in to comment.