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
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0ef35fc
Slider
Jan 10, 2020
ed11203
Tidy up
Jan 10, 2020
ffeee27
Exclude utils, constants and types from getAllComponents
nvlaarhoven Apr 14, 2020
e02ee89
Import Slider properly
nvlaarhoven Apr 14, 2020
c47b9a5
extend PureComponent
nvlaarhoven Apr 14, 2020
859a765
Get Component from props
nvlaarhoven Apr 14, 2020
7aaa249
Move Slider into /forms
nvlaarhoven Apr 14, 2020
c4109e4
Remove roe and __ from classNames
nvlaarhoven Apr 14, 2020
a6fb622
Improve SliderExample
nvlaarhoven Apr 14, 2020
1aac9fc
Improve slider styling
nvlaarhoven Apr 14, 2020
bdae232
Prettier
nvlaarhoven Apr 15, 2020
0e52aef
Improve classnames
nvlaarhoven Apr 15, 2020
8b64392
Put constants and types in slider file
nvlaarhoven Apr 15, 2020
a0e4051
Cleanup slider example
nvlaarhoven Apr 15, 2020
e9e6a76
Cleanup less
nvlaarhoven Apr 15, 2020
49cb546
Move utils into /utils folder
nvlaarhoven Apr 15, 2020
2bfa649
Cleanup slider logic
nvlaarhoven Apr 15, 2020
e214e0a
Update classnames in test
nvlaarhoven Apr 15, 2020
5de2d5a
Update snapshot
nvlaarhoven Apr 15, 2020
1d966cd
Undo change package-lock
nvlaarhoven Apr 15, 2020
9853064
Export allthethings
nvlaarhoven Apr 15, 2020
8740721
Provide docs for props
nvlaarhoven Apr 15, 2020
5d36dbf
Move @slider-z-index to Z indices
nvlaarhoven Apr 15, 2020
b55c632
Improve less
nvlaarhoven Apr 23, 2020
24d14fe
Prevents negatives
nvlaarhoven Apr 23, 2020
bc4e61d
Fix typo
nvlaarhoven Apr 23, 2020
6d9904b
More ES6y
nvlaarhoven Apr 23, 2020
e13d34a
Rename @slider-control-color to @slider-control-background
nvlaarhoven Apr 23, 2020
bbae8e9
Revert changing floor to ceil
nvlaarhoven Apr 23, 2020
e64f990
Install lodash to define range
nvlaarhoven Apr 23, 2020
9fcc157
Remove casts as (event: SyntheticMouseEvent) => void
nvlaarhoven Apr 23, 2020
0e5abcb
Move constrain into utils
nvlaarhoven Apr 23, 2020
a786774
Define function callOnChange
nvlaarhoven Apr 23, 2020
52d583f
Guard in case totalRange is 0
nvlaarhoven Apr 23, 2020
e35334b
Expect removeEventListener to have been called
nvlaarhoven Apr 23, 2020
bad3cf8
Check initialValues to avoid slider outside range
nvlaarhoven Apr 23, 2020
c5f4c58
Call onSlide whenever slider moves
nvlaarhoven Apr 24, 2020
4ed2140
Set @slider-control-border-radius such that control is circle
nvlaarhoven Apr 24, 2020
82bb780
Rename default to background
nvlaarhoven Apr 24, 2020
f8fa77b
Add prop to displayPopover
nvlaarhoven Apr 24, 2020
78e26f6
Add another example
nvlaarhoven Apr 24, 2020
b695bb4
Replaces values with popover
nvlaarhoven Apr 24, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@
"dependencies": {
"@types/classnames": "^2.2.0",
"@types/cookie": "^0.3.1",
"@types/lodash": "^4.14.150",
"@types/random-seed": "^0.3.2",
"@types/react": ">= 15",
"@types/react-dom": ">= 15",
"@types/react-transition-group": "^1.1.4",
"classnames": "^2.2.5",
"cookie": "^0.3.1",
"lodash": "^4.17.15",
"normalize.css": "^8.0.1",
"random-seed": "^0.3.0",
"react": ">= 15",
Expand Down
1 change: 1 addition & 0 deletions src/less/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
@import 'speech-bubble.less';
@import 'code-block.less';
@import 'highlight.less';
@import 'slider.less';
// NOTE: These must remain after the other imports
@import 'float.less';
@import 'display.less';
Expand Down
80 changes: 80 additions & 0 deletions src/less/slider.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
.slider {
padding: @padding-large;
padding-top: @padding-large * 2;

.bar {
height: @slider-bar-thickness;
position: relative;

.background {
position: absolute;
top: 0;
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?

right: 0;
width: 100%;
}
}

.range {
position: absolute;
top: 0;
height: 100%;
background-color: @slider-range-color;
z-index: @slider-z-index - 1;
}

.control {
position: relative;
width: @slider-control-width;
height: @slider-control-height;
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%);

background-color: @slider-control-background;
cursor: ew-resize;
border-radius: @slider-control-border-radius;
z-index: @slider-z-index;

.control-popover {
position: absolute;
display: inline-table;
top: -1.4em;
width: 2.5em;
height: 2em;
transform: translate(-30%, -50%);
Comment on lines +45 to +48
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%);

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;

border-radius: @border-radius-base;

span {
display: table-row;
}

&::before {
content: '';
position: absolute;
width: 0;
height: 0;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
bottom: -4px;
border-left: 10px solid transparent; // lesshint variableValue: false
border-right: 10px solid transparent; // lesshint variableValue: false
border-top: 10px solid @slider-control-popover-background; // lesshint variableValue: false
}
}
}

.range,
.control {
transition: all 0.2s ease-out;
}
}
}
10 changes: 10 additions & 0 deletions src/less/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
@modal-z-index: 1100;
@side-bar-z-index: 1200;
@highlight-z-index: 1300;
@slider-z-index: 2;

/* @end Z indices */

Expand Down Expand Up @@ -131,6 +132,15 @@
@table-hover: darken(@grey-lightest, 3%);
@table-border: @border-base;

@slider-bar-background: lighten(@grey-lighter, 8%);
@slider-bar-thickness: 5px;
@slider-range-color: @info;
@slider-control-width: 15px;
@slider-control-height: 15px;
@slider-control-background: @info;
@slider-control-border-radius: 20px;
@slider-control-popover-background: lighten(@info, 25%);

@content-box-background: @white;
@content-box-header-background: @primary-lightest;
@content-box-header-border: 1px solid @primary-lighter;
Expand Down
34 changes: 34 additions & 0 deletions src/ts/components/forms/slider.examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#### Examples

With initial values set and popover displayed:

```js
<Slider
displayPopover
onSlide={value => console.log(value)}
initialValue={{ from: 0, to: 700 }}
min={0}
max={1000}
step={10}
/>
```

Without initial values and without popover displayed:

```js
<Slider onSlide={value => console.log(value)} min={-100} max={100} step={1} />
```

#### Less variables

```less
@slider-bar-background: lighten(@grey-lighter, 8%);
@slider-bar-thickness: 5px;
@slider-z-index: 2;
@slider-range-color: @info;
@slider-control-width: 15px;
@slider-control-height: 15px;
@slider-control-background: @info;
@slider-control-border-radius: 20px;
@slider-control-popover-background: lighten(@info, 25%);
```
Loading