Skip to content

Commit d39970f

Browse files
author
Philip Weiss
committed
add css generating script and package.json hook
1 parent b42a856 commit d39970f

File tree

4 files changed

+39
-39
lines changed

4 files changed

+39
-39
lines changed

src/DefaultHandle.jsx

+15-31
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import PropTypes from 'prop-types';
33
import { forbidExtraProps } from 'airbnb-prop-types';
44
import { withStyles, withStylesPropTypes } from 'react-with-styles';
55

6-
import {
7-
DEFAULT_HANDLE_WIDTH_UNITS,
8-
BACKGROUND_HEIGHT_UNITS,
9-
VERTICAL,
10-
} from './constants/SliderConstants';
6+
import { VERTICAL } from './constants/SliderConstants';
117

128
import handlePropTypes, { handleDefaultProps } from './propTypes/HandlePropTypes';
139

@@ -52,10 +48,10 @@ DefaultHandle.propTypes = propTypes;
5248

5349
DefaultHandle.defaultProps = defaultProps;
5450

55-
export default withStyles(({ color, unit }) => ({
51+
export default withStyles(({ color, unit, constants }) => ({
5652
DefaultHandle_handle: {
57-
width: DEFAULT_HANDLE_WIDTH_UNITS * 3.8 * unit,
58-
height: DEFAULT_HANDLE_WIDTH_UNITS * 3.8 * unit,
53+
width: 2 * constants.DEFAULT_HANDLE_WIDTH * unit,
54+
height: 2 * constants.DEFAULT_HANDLE_WIDTH * unit,
5955
borderWidth: 1,
6056
borderStyle: 'solid',
6157
borderColor: color.grey,
@@ -65,7 +61,7 @@ export default withStyles(({ color, unit }) => ({
6561
zIndex: 2,
6662
boxShadow: `0 ${unit / 4}px ${unit / 4}px ${color.textDisabled}`,
6763
':focus': {
68-
boxShadow: `${color.focus} 0 0 2px 2px`,
64+
boxShadow: `${color.focus} 0 0 1px 1px`,
6965
},
7066

7167
':after': {
@@ -99,33 +95,21 @@ export default withStyles(({ color, unit }) => ({
9995
width: 1,
10096
left: 13,
10197
},
102-
103-
background: {
104-
borderRadius: 15,
105-
},
10698
},
10799

108100
DefaultHandle_handle__vertical: {
109-
marginTop: -(DEFAULT_HANDLE_WIDTH_UNITS * 1.9) * unit,
110-
left: ((BACKGROUND_HEIGHT_UNITS * 1.9) - (DEFAULT_HANDLE_WIDTH_UNITS * 1.9)) * unit,
111-
progress: {
112-
left: 2,
113-
width: 13,
114-
},
115-
handle: {
116-
left: -5,
117-
marginTop: -12,
101+
marginTop: -(constants.DEFAULT_HANDLE_WIDTH) * unit,
102+
left: (constants.BACKGROUND_HEIGHT - constants.DEFAULT_HANDLE_WIDTH) * unit,
118103

119-
':before': {
120-
top: 10,
121-
},
104+
':before': {
105+
top: 10,
106+
},
122107

123-
':after': {
124-
top: 13,
125-
left: 8,
126-
height: 1,
127-
width: 10,
128-
},
108+
':after': {
109+
top: 13,
110+
left: 8,
111+
height: 1,
112+
width: 10,
129113
},
130114
},
131115

src/DefaultProgressBar.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ export default withStyles(({ color, unit }) => ({
6060
},
6161

6262
DefaultProgressBar_progressBar: {
63-
backgroundColor: color.teal,
63+
backgroundColor: color.progressBar,
6464
position: 'absolute',
6565
},
6666

src/constants/SliderConstants.js

-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,5 @@ export const KEYS = {
1212
export const PERCENT_EMPTY = 0;
1313
export const PERCENT_FULL = 100;
1414
export const DEFAULT_STEP = 1;
15-
export const BACKGROUND_HEIGHT_UNITS = 0.5;
16-
export const DEFAULT_HANDLE_WIDTH_UNITS = 0.8;
1715
export const HORIZONTAL = 'horizontal';
1816
export const VERTICAL = 'vertical';

src/themes/DefaultTheme.js

+23-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,29 @@
1+
const core = {
2+
black: 'black',
3+
white: '#fcfcfc',
4+
grey: '#d8d8d8',
5+
teal: '#abc4e8',
6+
lightgrey: '#dbdbdb',
7+
};
8+
19
const DefaultTheme = {
210
unit: 8,
3-
responsive: {},
11+
12+
responsive: {
13+
mediumAndAbove: '@media (min-width: 744px)',
14+
largeAndAbove: '@media (min-width: 1128px)',
15+
},
16+
17+
constants: {
18+
DEFAULT_HANDLE_WIDTH: 1.5,
19+
BACKGROUND_HEIGHT: 0.25,
20+
},
21+
422
color: {
5-
black: 'black',
6-
white: '#fcfcfc',
7-
grey: '#d8d8d8',
8-
teal: '#abc4e8',
23+
...core,
24+
progressBar: core.teal,
25+
focus: core.teal,
26+
textDisabled: core.lightgrey,
927

1028
buttons: {
1129
defaultDisabledColor: 'blue',

0 commit comments

Comments
 (0)