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

Use react-range for input sliders to support IE #52

Merged
merged 9 commits into from
Oct 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
var React = require('react');
var { parseCSSColor } = require('csscolorparser');
var extend = require('xtend');
var Range = require('react-range');

var XYControl = require('./src/xy');

Expand Down Expand Up @@ -279,7 +280,7 @@ module.exports = React.createClass({
onChange={this._onXYChange.bind(null, colorAttribute)} />
</div>
<div className={`cp-colormode-slider cp-colormode-attribute-slider ${colorAttribute}`}>
<input
<Range
value={colorAttributeValue}
style={hueSlide}
onChange={this._onColorSliderChange.bind(null, colorAttribute)}
Expand Down Expand Up @@ -397,7 +398,7 @@ module.exports = React.createClass({
</fieldset>
</div>
<fieldset className='cp-fill-tile'>
<input
<Range
className='cp-alpha-slider-input'
value={a}
onChange={this._onAlphaSliderChange}
Copy link
Contributor

Choose a reason for hiding this comment

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

type=range here is implied and can be removed

Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
]
},
"scripts": {
"test": "npm run lint && browserify test/test.js | tap-closer | smokestack -b firefox",
"test": "npm run lint && browserify test/test.js | tap-closer | smokestack -b firefox | tap-status",
"lint": "eslint --no-eslintrc -c .eslintrc index.js src",
"start": "node server.js",
"build": "NODE_ENV=production browserify example/index.js | uglifyjs -c -m > example/bundle.js"
Expand All @@ -29,6 +29,7 @@
"colr-convert": "^1.0.4",
"csscolorparser": "^1.0.2",
"react": "^0.13.3",
"react-range": "0.0.5",
"xtend": "^4.0.0"
},
"devDependencies": {
Expand All @@ -41,7 +42,7 @@
"eslint-plugin-react": "^2.2.0",
"react-hot-loader": "^1.2.9",
"smokestack": "^3.3.0",
"tap-closer": "^1.0.0",
"tap-status": "^1.0.1",
"tape": "^4.0.0",
"uglify-js": "^2.4.20",
"webpack": "^1.12.0",
Expand Down
21 changes: 15 additions & 6 deletions test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,15 @@ test('component basics', (t) => {
t.equal(colorSlider.classList.contains('v'), true, 'slider for value is present when HSV (v) input is in focus.');

colorSliderInput.value = 0;
TestUtils.Simulate.change(colorSliderInput);
TestUtils.Simulate.click(colorSliderInput);

t.equal(v.value, '0', 'HSV (v) input attribute changed to 0 after adjusting the color slider');
TestUtils.Simulate.change(v);
TestUtils.Simulate.click(v);

t.equal(hex.value, '000000', 'input updates HEX to #000000');

alphaSliderInput.value = 50;
TestUtils.Simulate.change(alphaSliderInput);
TestUtils.Simulate.click(alphaSliderInput);
t.equal(onChangeObj.a, 0.5, 'alpha output is adjusted');

t.end();
Expand Down Expand Up @@ -141,6 +141,7 @@ test('component options', (t) => {
b: 0,
a: 1,
hex: '000',
input: 'hex',
mode: 'hsv',
colorAttribute: 'g'
};
Expand Down Expand Up @@ -176,6 +177,7 @@ test('rgb value', (t) => {
b: 255,
a: 1,
hex: '0ff',
input: 'hex',
mode: 'rgb',
colorAttribute: 'h'
};
Expand All @@ -199,8 +201,7 @@ test('rgba value', (t) => {
);

t.ok(colorpickr, 'colorpickr component with options is rendered in document');

TestUtils.Simulate.change(TestUtils.findRenderedDOMComponentWithClass(colorpickr, 'cp-hex-input').getDOMNode());
TestUtils.Simulate.click(TestUtils.findRenderedDOMComponentWithClass(colorpickr, 'cp-mode-hsv').getDOMNode());

const expectOnChangeToBe = {
h: 180,
Expand All @@ -211,10 +212,18 @@ test('rgba value', (t) => {
b: 255,
a: 0.5,
hex: '0ff',
mode: 'rgb',
mode: 'hsv',
colorAttribute: 'h'
};

t.deepEqual(onChangeObj, expectOnChangeToBe, 'onChange object reflects options passed');
t.end();
});

// close the smokestack window once tests are complete
test('shutdown', function(t) {
t.end();
setTimeout(function() {
window.close();
});
});