Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(react-slider) - Adding Marks #19427

Merged
merged 73 commits into from
Sep 1, 2021

Conversation

czearing
Copy link
Collaborator

Pull request checklist

Description of changes

Adding the basic marks prop to the Slider component.

In this pull request the marks prop accepts:

  1. Boolean: If true marks are visible for each step.
  2. number[]: Marks will be displayed at each provided number.

image

CodeSandbox Demo

This is the full demo of the marks prop.
https://codesandbox.io/s/marked-slider-component-q5bpd?file=/src/App.js

…eat/slider-basic-marks

# Conflicts:
#	packages/react-slider/etc/react-slider.api.md
#	packages/react-slider/src/components/Slider/useSlider.ts
#	packages/react-slider/src/components/Slider/useSliderState.tsx
#	packages/react-slider/src/components/Slider/useSliderStyles.ts
packages/react-slider/Spec.md Outdated Show resolved Hide resolved
outline: 'none',
zIndex: '1',
whiteSpace: 'nowrap',
'& .ms-Slider-mark': {
Copy link
Member

Choose a reason for hiding this comment

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

I'm not seeing ms-Slider-mark applied anywhere? Also it seems like in converged it's more common to have a separate style mark and apply that where needed rather than hardcoding class names.

Copy link
Member

Choose a reason for hiding this comment

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

It is applied in useSliderState since it goes into a JSX element that is being dynamically generated.

Having a separate mark style, while possible, would require having a makeStyles call in a non use[Component]Styles file, which I don't know if it's something we want either, although I guess it could still be defined and exported here and just imported in the other file.

Copy link
Member

Choose a reason for hiding this comment

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

Got it. Maybe if the class name could be shared in a const with a comment about why it's needed?

Copy link
Member

Choose a reason for hiding this comment

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

@czearing would you mind maybe moving that to a const in the other file and importing it here? Or maybe putting the const in here and importing it in useSliderState might be the better thing to do? Either way, you'd have to individually specify the exports from these files in index.ts to ensure you're not exporting something you don't want to.

outline: 'none',
zIndex: '1',
whiteSpace: 'nowrap',
'& .ms-Slider-mark': {
Copy link
Member

Choose a reason for hiding this comment

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

It is applied in useSliderState since it goes into a JSX element that is being dynamically generated.

Having a separate mark style, while possible, would require having a makeStyles call in a non use[Component]Styles file, which I don't know if it's something we want either, although I guess it could still be defined and exported here and just imported in the other file.

outline: 'none',
zIndex: '1',
whiteSpace: 'nowrap',
'& .ms-Slider-mark': {
Copy link
Member

Choose a reason for hiding this comment

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

@czearing would you mind maybe moving that to a const in the other file and importing it here? Or maybe putting the const in here and importing it in useSliderState might be the better thing to do? Either way, you'd have to individually specify the exports from these files in index.ts to ensure you're not exporting something you don't want to.

Copy link
Member

@ecraig12345 ecraig12345 left a comment

Choose a reason for hiding this comment

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

Minor comments (and +1 on Mak's comment) but generally looks good!

…eat/slider-basic-marks

# Conflicts:
#	packages/react-slider/src/components/Slider/Slider.test.tsx
#	packages/react-slider/src/components/Slider/useSliderState.tsx
@czearing czearing merged commit 1971082 into microsoft:master Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants