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

[Core] MultiSlider component #2536

Merged
merged 65 commits into from
Jun 12, 2018
Merged

[Core] MultiSlider component #2536

merged 65 commits into from
Jun 12, 2018

Conversation

jscheiny
Copy link
Contributor

@jscheiny jscheiny commented May 22, 2018

Checklist


Changes proposed in this pull request:

This adds a very general MultiRangeSlider component that ultimately should be able to subsume the Slider and RangeSlider components.

Notes about the component API:

  • Instead of taking a value/values the component takes a list of handles specified by props. Each handle has:
  • value - where it gets placed on the slider
  • type - specifies how the slider handle should be displayed
    • "full" - handle appears like it does in a Slider (default)
    • "lower" - handle appears like the first slider in a RangeSlider
    • "upper" - handle appears like the second slider in a RangeSlider
  • trackIntent{Above,Below} specifies the color of the track fill above and below (numerically) of the given handle.

Handles are always displayed in ascending numeric order and the values that are returned by onChange and onRelease are always sorted.

In addition, MultiRangeSlider takes a defaultTrackIntent prop which is used in the resolution of how to render the color of the track between two given handles. The way that this is resolved is as follows (and is one of my concerns about the API).

  • If the left handle has an above intent, use that
  • If the right handle has a below intent, use that
  • If the component has a default intent, use that
  • Otherwise don't color that section

Important: Note that there is a difference between the NONE intent and the absence of an intent entirely (undefined). The former will render a gray track between the two handles and the latter will fall-through to the next color in the hierarchy above.

I previously allowed the specification of colors instead of intents but that didn't seem very blueprint-y.


Reviewers should focus on:

I have explicitly not written tests/docs for this yet, as I would first like to iterate on the API as I'm not convinced what I've written is particularly nice (worked for our use case but don't know if it generalizes well). Once we've iterated and nailed down an API I will gladly write tests and docs for this component.

I've written some questions in the code, but one additional question I have is should this component live in labs first to incubate before moving into core?


Not addressed in this PR (requires follow-up):

To keep this PR simple(r) and easy(er) to review, I have not made many changes to the existing slider components but in 1-2 follow up PRs I would like to:

  1. Refactor Slider and RangeSlider to be simple wrappers around MultiRangeSlider
  2. Remove CoreSlider and refactor into MultiRangeSlider

The second one is questionable, especially if there are plans to add a slider that does not fit into the multi range slider model.


Screenshots

Two tailed slider:

screen shot 2018-04-19 at 10 43 24 am

Disabled:

screen shot 2018-04-19 at 11 09 44 am

One tailed:

screen shot 2018-04-19 at 11 10 39 am

Weird:

screen shot 2018-04-19 at 11 12 27 am

Vertical:

screen shot 2018-04-19 at 11 14 13 am

In action:

mulit-range-slider

@jscheiny jscheiny mentioned this pull request May 22, 2018
3 tasks
@blueprint-bot
Copy link

Fix lint

Preview: documentation | landing | table

@giladgray giladgray self-requested a review May 22, 2018 18:12
* or between handles for `RangeSlider`.
* @default true
*/
showTrackFill?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

@jscheiny is this prop respected by your impl?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@blueprint-bot
Copy link

Fix tests

Preview: documentation | landing | table

@giladgray giladgray added this to the 3.0.0 milestone Jun 4, 2018
@blueprint-bot
Copy link

only one track element, remove some classes

Preview: documentation | landing | table

@blueprint-bot
Copy link

fix test import

Preview: documentation | landing | table

giladgray and others added 2 commits June 7, 2018 13:58
* write Handle tests for onChange/onRelease movement

* Handle maybe calls onChange when released (if different from prop)

* rewrite sliderTestUtils: simulateMovement() does it all

* enable vertical Handle tests, more utils refactors

* refactor Slider & RangeSlider test suites: test handles & track

* rewrite MultiSlider tests

* tests imports

* fix Slider initialValue and displayName
@blueprint-bot
Copy link

MultiSlider tests (#2576)

Preview: documentation | landing | table

@giladgray
Copy link
Contributor

example is broken. will fix shortly

* maybeRenderAxis => renderLabels

* renderFill => renderTracks

* border-radius only on track, remove start/end modifiers from segments

* fix test utils

* add test for handles outside range

* fix Label usage in example
@blueprint-bot
Copy link

MultiSlider refactors (#2569)

Preview: documentation | landing | table

* Slider docs

* refactor MultiSliderExample
@blueprint-bot
Copy link

MultiSlider docs (#2577)

Preview: documentation | landing | table

* utils use ComponentType to support SFCs

* drop Slider prefix from Handle types

* Handle component extends IHandleProps interface

* SliderHandle => MultiSlider.Handle

* update tests

* fix Handle tests
@blueprint-bot
Copy link

SliderHandle => MultiSlider.Handle (#2578)

Preview: documentation | landing | table

Copy link
Contributor

@giladgray giladgray left a comment

Choose a reason for hiding this comment

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

update on what this PR actually does:

  • replace CoreSlider with MultiSlider component that supports arbitrary handles and track segments
    • 👍 CoreSlider was internal, so this isn't actually a breaking change
  • refactor Slider and RangeSlider to compose MultiSlider internally (instead of extending CoreSlider
    • 👍 APIs unchanged for these two components
  • refactor tests by introducing suite for Handle and greatly simplifying Slider/RangeSlider suites

value: number;

/** Whether this handle is non-interactive. */
disabled?: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think this prop is ever read.

* MultiSlider fixes

* Remove disabled prop

* Fix typings
@blueprint-bot
Copy link

MultiSlider fixes (#2588)

Preview: documentation | landing | table

@blueprint-bot
Copy link

default prop values in docs

Preview: documentation | landing | table

@giladgray giladgray merged commit 00bbef6 into develop Jun 12, 2018
@giladgray giladgray deleted the js/multi-range-slider branch June 12, 2018 18:49
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.

4 participants