Skip to content

Commit

Permalink
refactor(slider): ♻️ add base states to props states
Browse files Browse the repository at this point in the history
  • Loading branch information
navin-moorthy committed May 24, 2022
1 parent 6022e8f commit fe38843
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/meter/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from "./__utils";
export * from "./meter-base";
export * from "./meter-state";
7 changes: 6 additions & 1 deletion src/slider/slider-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function useSliderState(props: SliderStateProps): SliderState {
const trackRef = React.useRef<HTMLElement>(null);
const sliderProps = useSlider(rest, state, trackRef);

return { ...sliderProps, trackRef };
return { ...sliderProps, trackRef, baseState: state };
}

export type SliderState = {
Expand All @@ -32,6 +32,11 @@ export type SliderState = {

/** Props for the output element, displaying the value of the slider thumbs. */
outputProps: React.OutputHTMLAttributes<HTMLOutputElement>;

/**
* Object returned by the `useSliderBaseState` hook.
*/
baseState: SliderBaseState;
};

export type SliderStateProps = AriaSliderProps & {
Expand Down
7 changes: 6 additions & 1 deletion src/slider/slider-thumb-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ export function useSliderThumbState(
state,
);

return { ...sliderThumbProps, inputRef };
return { ...sliderThumbProps, inputRef, baseState: state };
}

export type SliderThumbState = SliderThumbAria & {
/** A ref to the thumb input element. */
inputRef: React.RefObject<HTMLInputElement>;

/**
* Object returned by the `useSliderBaseState` hook.
*/
baseState: SliderBaseState;
};

export type SliderThumbStateProps = AriaSliderThumbProps & {
Expand Down

1 comment on commit fe38843

@vercel
Copy link

@vercel vercel bot commented on fe38843 May 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.