Skip to content

Conversation

@tom-vx51
Copy link
Collaborator

Rationale

Implement a Slider component which supports:

  • Single or multiple slider knobs
  • Bound input fields for knob values
  • Basic value validation

Changes

  • Implement Slider and supporting components

Testing

storybook, npm run build && npm run test
Screenshot 2025-12-30 at 11 40 15 AM

@tom-vx51 tom-vx51 requested a review from a team as a code owner December 30, 2025 19:51

const valueString = value!.toString();

return (
Copy link
Contributor

Choose a reason for hiding this comment

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

it might be worth adding some console.warn here to alert the developer as well?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

leaving out for now since this validator is called on every value change; don't want to pollute the console too much

* Type alias for a predicate function.
*/
export type Validator = (value: string | number | null | undefined) => boolean;

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe adding a validator so that if value is an array it has length of 1-2?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

addressed validation via component wrappers

multi?: boolean;
onChange?: (value: number | number[]) => void;
step?: number;
value?: number | number[];
Copy link
Contributor

Choose a reason for hiding this comment

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

is there ever a case where value as an array will have one value instead of two?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

it shouldn't, but it'll probably happen at some point. I'll add some validation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added SingleValueSlider and MultiValueSlider variants which enforce type restrictions; Slider now exists as BaseSlider and can still be used in the same way, but we should advocate for using one of the strongly-typed variants whenever possible

max: number;
maxLabel?: ReactNode;
multi?: boolean;
onChange?: (value: number | number[]) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I've been consistent with this - I've been working under the assumption that these components are always "controlled". Do we want to support cases for uncontrolled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think assuming everything is controlled is fine for now, I'm not aware of any cases where we need uncontrolled behavior.

I'm guessing we'll want it at some point, so I'm adding uncontrolled whenever I feel motivated to do the work. Not a priority right now though

@tom-vx51 tom-vx51 merged commit 374c34a into develop Jan 6, 2026
1 check passed
@tom-vx51 tom-vx51 deleted the feat/slider branch January 6, 2026 21:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants