Skip to content

Slider #2#329

Open
ghost wants to merge 42 commits intomasterfrom
slider#2
Open

Slider #2#329
ghost wants to merge 42 commits intomasterfrom
slider#2

Conversation

@ghost
Copy link
Copy Markdown

@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
Comment thread src/less/slider.less Outdated
Comment thread src/less/slider.less Outdated
Comment thread src/less/slider.less Outdated
Comment thread src/less/variables.less Outdated
Comment thread src/ts/components/forms/slider.examples.md
Comment thread src/ts/utils/slider.ts Outdated
Comment thread src/ts/utils/slider.ts Outdated
Comment thread src/ts/utils/slider.ts Outdated
Comment thread src/ts/utils/slider.ts Outdated
step: number
) => {
const totalRange = max - min;
return (step - min) / totalRange;
Copy link
Copy Markdown
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.

Comment thread tests/slider.tsx
Comment thread src/ts/components/forms/slider.tsx Outdated
);

const initialValue = {
from: props.initialValue ? props.initialValue.from : min,
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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).

Comment thread src/less/slider.less
transform: translate(-30%, -50%);
text-align: center;
background-color: @slider-control-popover-background;
font-size: 11px;
Copy link
Copy Markdown
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 thread src/less/slider.less
Comment on lines +45 to +48
top: -1.4em;
width: 2.5em;
height: 2em;
transform: translate(-30%, -50%);
Copy link
Copy Markdown
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%);

Comment thread src/less/slider.less
top: 50%;
left: 0;
float: left;
transform: translate(-100%, -50%);
Copy link
Copy Markdown
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%);

Comment thread src/less/slider.less
height: 100%;
background-color: @slider-bar-background;

&:last-of-type {
Copy link
Copy Markdown
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