Skip to content

Commit 2b7e6e5

Browse files
Migrated to emotion
1 parent da3a5bf commit 2b7e6e5

20 files changed

Lines changed: 375 additions & 140 deletions

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# Version 1.2.0
2+
Released 2018-09-08
3+
4+
- Migrated from `glamorous` to `emotion`
5+
- Dragging now only activates when the left mouse button is clicked
6+
17
# Version 1.1.0
28
Released 2018-03-28
39

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,3 @@ All other props (not documented here) will be passed on to the root element.
119119
#### How custom styles work
120120
When a function is passed to a `style` prop rather than an object, it is expected to return an object.
121121
The style function will be called with all props that that component has (except for the `style` and `children` props and any internal callbacks). The return value of the function will be used as style (see the [demo repo](https://github.com/rafaelklaessen/react-multi-bar-slider-demo) for an example).
122-
123-
## Caveats
124-
When the `MultiSlider`, `Progress` or `Dot` components are wrapped with glamorous (eg `glamorous(MultiSlider)`), glamorous breaks. I don't know how to fix this, so don't wrap them :)

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-multi-bar-slider",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "Slider component with multiple bars for React",
55
"repository": {
66
"type": "git",
@@ -19,8 +19,7 @@
1919
"react multi slider"
2020
],
2121
"peerDependencies": {
22-
"glamor": "^2.x",
23-
"glamorous": "^4.x",
22+
"emotion": "^9.x",
2423
"prop-types": "^15.x",
2524
"react": "^15.3.x || ^16.x",
2625
"react-dom": "^15.3.x || ^16.x"
@@ -41,17 +40,17 @@
4140
"babel-preset-react": "^6.24.1",
4241
"babel-preset-stage-0": "^6.24.1",
4342
"clean-webpack-plugin": "^0.1.16",
43+
"emotion": "^9.2.8",
4444
"enzyme": "^3.3.0",
4545
"enzyme-adapter-react-16": "^1.1.1",
4646
"eslint": "^4.9.0",
4747
"eslint-plugin-react": "^7.4.0",
48-
"glamor": "^2.20.40",
49-
"glamorous": "^4.12.1",
5048
"jest": "^21.2.1",
5149
"jest-cli": "^22.4.3",
5250
"prop-types": "^15.6.1",
5351
"react": "^16.2.0",
5452
"react-dom": "^16.2.0",
53+
"react-emotion": "^9.2.8",
5554
"react-test-renderer": "^16.2.0",
5655
"webpack": "^3.8.1"
5756
}

src/Dot/DotIcon.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import PropTypes from 'prop-types';
2-
import glamorous from 'glamorous';
2+
import styled from 'react-emotion';
33

4-
const DotIcon = glamorous.img({
4+
const DotIcon = styled('img')({
55
position: 'absolute',
66
transform: 'translateX(-50%)',
77
userDrag: 'none',
88
userSelect: 'none'
9-
}, ({ width, height }) => ({
9+
}, ({ width, height, css }) => ({
1010
width,
11-
height
11+
height,
12+
...css
1213
}));
1314

1415
DotIcon.displayName = 'DotIcon';
@@ -21,7 +22,8 @@ DotIcon.propTypes = {
2122

2223
DotIcon.defaultProps = {
2324
width: 50,
24-
height: 50
25+
height: 50,
26+
css: null
2527
};
2628

2729
export default DotIcon;

src/Dot/StyledDot.js

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import PropTypes from 'prop-types';
2-
import glamorous from 'glamorous';
2+
import styled from 'react-emotion';
33
import transition from '../utils/transition';
44

5-
const StyledDot = glamorous.span({
5+
const StyledDot = styled('span')({
66
position: 'absolute',
77
right: 0,
88
display: 'block',
99
zIndex: 5,
1010
borderRadius: '50%'
11-
}, ({ hasIcon, width, height, color, reversed, noTransition }) => ({
11+
}, ({ hasIcon, width, height, color, reversed, noTransition, css }) => ({
1212
top: hasIcon ? 0 : '50%',
1313
left: reversed ? 0 : 'auto',
1414
right: reversed ? 'auto' : 0,
@@ -18,7 +18,8 @@ const StyledDot = glamorous.span({
1818
width: hasIcon ? 0 : width,
1919
height: hasIcon ? 0 : height,
2020
backgroundColor: hasIcon ? 'transparent' : color,
21-
transition: noTransition ? 'none' : transition
21+
transition: noTransition ? 'none' : transition,
22+
...css
2223
}));
2324

2425
StyledDot.propTypes = {
@@ -33,7 +34,8 @@ StyledDot.propTypes = {
3334

3435
StyledDot.defaultProps = {
3536
width: 28,
36-
height: 28
37+
height: 28,
38+
css: null
3739
};
3840

3941
export default StyledDot;

src/Dot/__tests__/__snapshots__/DotIcon.test.js.snap

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
exports[`DotIcon.js matches the snapshot 1`] = `
44
<img
5-
className="css-19tq53f"
5+
className="css-1gn67lo"
6+
height={45}
7+
width={45}
68
/>
79
`;

src/Dot/__tests__/__snapshots__/StyledDot.test.js.snap

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
exports[`StyledDot.js matches the snapshot 1`] = `
44
<span
5-
className="css-1c7oaf0"
5+
className="css-r1lieg"
6+
color="green"
7+
height={30}
8+
reversed={false}
9+
width={30}
610
/>
711
`;

src/MultiSlider/SlidableZone.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import PropTypes from 'prop-types';
2-
import glamorous from 'glamorous';
2+
import styled from 'react-emotion';
33

4-
const SlidableZone = glamorous.div({
4+
const SlidableZone = styled('div')({
55
position: 'absolute',
66
width: '100%'
77
}, ({ size, zIndex }) => ({

src/MultiSlider/StyledSlider.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
import PropTypes from 'prop-types';
2-
import glamorous from 'glamorous';
2+
import styled from 'react-emotion';
33
import transition from '../utils/transition';
44
import getHalf from '../utils/getHalf';
55

6-
const StyledSlider = glamorous.div({
6+
const StyledSlider = styled('div')({
77
position: 'relative',
88
height: 14,
99
boxSizing: 'border-box',
1010
transition
11-
}, ({ width, height, backgroundColor, roundedCorners, readOnly }) => ({
11+
}, ({ width, height, backgroundColor, roundedCorners, readOnly, css }) => ({
1212
width,
1313
height,
1414
backgroundColor,
1515
borderRadius: roundedCorners ? getHalf(height) : 0,
16-
cursor: readOnly ? 'auto' : 'pointer'
16+
cursor: readOnly ? 'auto' : 'pointer',
17+
...css
1718
}));
1819

1920

@@ -32,4 +33,8 @@ StyledSlider.propTypes = {
3233
css: PropTypes.object.isRequired
3334
};
3435

36+
StyledSlider.defaultProps = {
37+
css: null
38+
};
39+
3540
export default StyledSlider;

src/MultiSlider/__tests__/__snapshots__/SlidableZone.test.js.snap

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
exports[`SlidableZone.js matches the snapshot 1`] = `
44
<div
5-
className="css-t0d97c"
5+
className="css-1r9s984"
6+
size={40}
67
/>
78
`;

0 commit comments

Comments
 (0)