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

Slider #2 #329

Open
wants to merge 42 commits into
base: master
Choose a base branch
from
Open

Slider #2 #329

wants to merge 42 commits into from

Conversation

ghost
Copy link

@ghost ghost commented Jan 10, 2020

@nvlaarhoven nvlaarhoven force-pushed the slider#2 branch 2 times, most recently from 008d77f to ab7f3d4 Compare April 15, 2020 14:51
src/less/slider.less Outdated Show resolved Hide resolved
src/less/slider.less Outdated Show resolved Hide resolved
src/less/slider.less Outdated Show resolved Hide resolved
src/less/variables.less Outdated Show resolved Hide resolved
src/ts/components/forms/slider.examples.md Show resolved Hide resolved
src/ts/utils/slider.ts Outdated Show resolved Hide resolved
src/ts/utils/slider.ts Outdated Show resolved Hide resolved
src/ts/utils/slider.ts Outdated Show resolved Hide resolved
step: number
) => {
const totalRange = max - min;
return (step - min) / totalRange;
Copy link
Contributor

Choose a reason for hiding this comment

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

You should guard this in case the value is zero.

tests/slider.tsx Show resolved Hide resolved
);

const initialValue = {
from: props.initialValue ? props.initialValue.from : min,
Copy link
Contributor

@JakeSidSmith JakeSidSmith Apr 16, 2020

Choose a reason for hiding this comment

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

This initial value stuff should probably do some smart checking if the min is larger than the max stuff. Same for the min and max values themselves. Otherwise we may end up with a weird inverted slider.

Thinking about it... we may also have issues with negative numbers. What happens if the min is -100 and the max is 0?

Copy link
Contributor

@nvlaarhoven nvlaarhoven Apr 23, 2020

Choose a reason for hiding this comment

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

Agree we should check if from < to and probably also if initial values are within range 👍

I checked and slider with negative values works absolutely fine.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't think we can check if min is smaller than max using TS so have just made sure the initialValues are correct

nvlaarhoven and others added 7 commits April 23, 2020 11:41
Co-Authored-By: Jake 'Sid' Smith <jake@dabapps.com>
Co-Authored-By: Jake 'Sid' Smith <jake@dabapps.com>
Co-Authored-By: Jake 'Sid' Smith <jake@dabapps.com>
Co-Authored-By: Jake 'Sid' Smith <jake@dabapps.com>
Math.ceil won't work when the value is an integer
Copy link
Contributor

@JakeSidSmith JakeSidSmith left a comment

Choose a reason for hiding this comment

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

We should be able to check and handle from/to and min/max being smaller than one another, or dividing by zero.

Also, what I meant when we discussed this in Slack was that the onChange should be what is now called onSlide, as this is standard for inputs. Just that it shouldn't only be called when released, but called every time the value changes.

Finally: I didn't initially check the markup of the component, but I now realize I don't know why there is a background element, let alone 2. The background color should just be applied to the wrapper? And we could remove the getControlStyle logic completely if the controls are just rendered inside the range (position absoluted to either side).

transform: translate(-30%, -50%);
text-align: center;
background-color: @slider-control-popover-background;
font-size: 11px;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
font-size: 11px;
font-size: @font-size-small;

Comment on lines +45 to +48
top: -1.4em;
width: 2.5em;
height: 2em;
transform: translate(-30%, -50%);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
top: -1.4em;
width: 2.5em;
height: 2em;
transform: translate(-30%, -50%);
top: 0;
left: 50%;
transform: translate(-50%, -100%);

top: 50%;
left: 0;
float: left;
transform: translate(-100%, -50%);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
transform: translate(-100%, -50%);
transform: translate(-50%, -50%);

height: 100%;
background-color: @slider-bar-background;

&:last-of-type {
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 more than one background?

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.

2 participants