Skip to content

Commit

Permalink
removeAlpha
Browse files Browse the repository at this point in the history
  • Loading branch information
casesandberg committed Jun 9, 2016
1 parent 8129bed commit 364fd11
Show file tree
Hide file tree
Showing 13 changed files with 251 additions and 80 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.2.0 (8 June 2016)

- `disableAlpha` on Chrome and Sketch pickers

## 2.1.1 (8 June 2016)

- Fix ChromeFields icon highlight
Expand Down
179 changes: 115 additions & 64 deletions build/bundle.js

Large diffs are not rendered by default.

22 changes: 22 additions & 0 deletions docs/documentation/03.04-disableAlpha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
id: api-disableAlpha
title: disableAlpha
---

Use `disableAlpha` to remove the alpha fields on Chrome and Sketch color pickers.

```
import React from 'react';
import { SketchPicker } from 'react-color';
class Component extends React.Component {
render() {
return (
<SketchPicker
disableAlpha={ true }
onChangeComplete={ this.handleChangeComplete }
/>
);
}
}
```
22 changes: 20 additions & 2 deletions lib/components/chrome/Chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ var Chrome = exports.Chrome = function (_ReactCSS$Component) {
Absolute: '0px 0px 0px 0px',
borderRadius: '8px',
boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.1)',
background: 'rgba(' + this.props.rgb.r + ', ' + this.props.rgb.g + ', ' + this.props.rgb.b + ', ' + this.props.rgb.a + ')'
background: 'rgba(' + this.props.rgb.r + ', ' + this.props.rgb.g + ', ' + this.props.rgb.b + ', ' + this.props.rgb.a + ')',
zIndex: '2'
},
toggles: {
flex: '1'
Expand All @@ -125,12 +126,29 @@ var Chrome = exports.Chrome = function (_ReactCSS$Component) {
Alpha: {
radius: '2px'
}
},
'disableAlpha': {
color: {
width: '22px'
},
alpha: {
display: 'none'
},
hue: {
marginBottom: '0px'
},
swatch: {
width: '10px',
height: '10px',
marginTop: '0px'
}
}
};
}
}, {
key: 'render',
value: function render() {
console.log(this.props.rgb);
return _react2.default.createElement(
'div',
{ style: this.styles().picker },
Expand Down Expand Up @@ -170,7 +188,7 @@ var Chrome = exports.Chrome = function (_ReactCSS$Component) {
)
)
),
_react2.default.createElement(_ChromeFields2.default, _extends({}, this.props, { onChange: this.handleChange }))
_react2.default.createElement(_ChromeFields2.default, _extends({}, this.props, { onChange: this.handleChange, disableAlpha: this.props.disableAlpha }))
)
);
}
Expand Down
13 changes: 11 additions & 2 deletions lib/components/chrome/ChromeFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ var ChromeFields = exports.ChromeFields = function (_ReactCSS$Component) {
paddingLeft: '6px',
width: '100%'
},
alpha: {
paddingLeft: '6px',
width: '100%'
},
toggle: {
width: '32px',
textAlign: 'right',
Expand Down Expand Up @@ -169,6 +173,11 @@ var ChromeFields = exports.ChromeFields = function (_ReactCSS$Component) {
}
}
}
},
'disableAlpha': {
alpha: {
display: 'none'
}
}
};
}
Expand Down Expand Up @@ -223,7 +232,7 @@ var ChromeFields = exports.ChromeFields = function (_ReactCSS$Component) {
),
_react2.default.createElement(
'div',
{ style: this.styles().field },
{ style: this.styles().alpha },
_react2.default.createElement(_common.EditableInput, _extends({}, this.styles().Input, { label: 'a', value: this.props.rgb.a, arrowOffset: .01, onChange: this.handleChange }))
)
);
Expand All @@ -248,7 +257,7 @@ var ChromeFields = exports.ChromeFields = function (_ReactCSS$Component) {
),
_react2.default.createElement(
'div',
{ style: this.styles().field },
{ style: this.styles().alpha },
_react2.default.createElement(_common.EditableInput, _extends({}, this.styles().Input, { label: 'a', value: this.props.hsl.a, arrowOffset: .01, onChange: this.handleChange }))
)
);
Expand Down
2 changes: 1 addition & 1 deletion lib/components/material/Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var Material = exports.Material = function (_ReactCSS$Component) {
color: '#333',
padding: '0px',
border: '0px',
borderBottom: '2px solid #' + this.props.hex,
borderBottom: '2px solid ' + this.props.hex,
outline: 'none',
height: '30px'
},
Expand Down
13 changes: 12 additions & 1 deletion lib/components/sketched/Sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,17 @@ var Sketch = exports.Sketch = function (_ReactCSS$Component) {
radius: '2px',
shadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)'
}
},
'disableAlpha': {
color: {
height: '10px'
},
hue: {
height: '10px'
},
alpha: {
display: 'none'
}
}
};
}
Expand Down Expand Up @@ -162,7 +173,7 @@ var Sketch = exports.Sketch = function (_ReactCSS$Component) {
_react2.default.createElement(
'div',
{ style: this.styles().fields },
_react2.default.createElement(_SketchFields2.default, _extends({}, this.props, { onChange: this.handleChange }))
_react2.default.createElement(_SketchFields2.default, _extends({}, this.props, { onChange: this.handleChange, disableAlpha: this.props.disableAlpha }))
),
_react2.default.createElement(
'div',
Expand Down
11 changes: 10 additions & 1 deletion lib/components/sketched/SketchFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ var ShetchFields = exports.ShetchFields = function (_ReactCSS$Component) {
flex: '1',
paddingLeft: '6px'
},
alpha: {
flex: '1',
paddingLeft: '6px'
},
double: {
flex: '2'
},
Expand All @@ -117,6 +121,11 @@ var ShetchFields = exports.ShetchFields = function (_ReactCSS$Component) {
}
}
}
},
'disableAlpha': {
alpha: {
display: 'none'
}
}
};
}
Expand Down Expand Up @@ -148,7 +157,7 @@ var ShetchFields = exports.ShetchFields = function (_ReactCSS$Component) {
),
_react2.default.createElement(
'div',
{ style: this.styles().single },
{ style: this.styles().alpha },
_react2.default.createElement(_common.EditableInput, _extends({}, this.styles().Input, { label: 'a', value: Math.round(this.props.rgb.a * 100), onChange: this.handleChange, dragLabel: 'true', dragMax: '100' }))
)
);
Expand Down
20 changes: 19 additions & 1 deletion src/components/chrome/Chrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export class Chrome extends ReactCSS.Component {
borderRadius: '8px',
boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.1)',
background: 'rgba(' + this.props.rgb.r + ', ' + this.props.rgb.g + ', ' + this.props.rgb.b + ', ' + this.props.rgb.a + ')',
zIndex: '2',
},
toggles: {
flex: '1',
Expand All @@ -75,6 +76,22 @@ export class Chrome extends ReactCSS.Component {
radius: '2px',
},
},
'disableAlpha': {
color: {
width: '22px',
},
alpha: {
display: 'none',
},
hue: {
marginBottom: '0px',
},
swatch: {
width: '10px',
height: '10px',
marginTop: '0px',
},
},
}
}

Expand All @@ -83,6 +100,7 @@ export class Chrome extends ReactCSS.Component {
}

render(): any {
console.log(this.props.rgb)
return (
<div is="picker">
<div is="saturation">
Expand All @@ -105,7 +123,7 @@ export class Chrome extends ReactCSS.Component {
</div>
</div>
</div>
<ChromeFields {...this.props} onChange={ this.handleChange } />
<ChromeFields {...this.props} onChange={ this.handleChange } disableAlpha={ this.props.disableAlpha } />
</div>
</div>
)
Expand Down
17 changes: 13 additions & 4 deletions src/components/chrome/ChromeFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class ChromeFields extends ReactCSS.Component {
paddingLeft: '6px',
width: '100%',
},
alpha: {
paddingLeft: '6px',
width: '100%',
},
toggle: {
width: '32px',
textAlign: 'right',
Expand All @@ -39,7 +43,7 @@ export class ChromeFields extends ReactCSS.Component {
marginRight: '-4px',
marginTop: '12px',
cursor: 'pointer',
position: 'relative'
position: 'relative',
},
iconHighlight: {
position: 'absolute',
Expand Down Expand Up @@ -75,6 +79,11 @@ export class ChromeFields extends ReactCSS.Component {
},
},
},
'disableAlpha': {
alpha: {
display: 'none',
},
},
}
}

Expand Down Expand Up @@ -175,7 +184,7 @@ export class ChromeFields extends ReactCSS.Component {
<div is="field">
<EditableInput is="Input" label="b" value={ this.props.rgb.b } onChange={ this.handleChange } />
</div>
<div is="field">
<div is="alpha">
<EditableInput is="Input" label="a" value={ this.props.rgb.a } arrowOffset={ .01 } onChange={ this.handleChange } />
</div>
</div>
Expand All @@ -190,7 +199,7 @@ export class ChromeFields extends ReactCSS.Component {
<div is="field">
<EditableInput is="Input" label="l" value={ Math.round(this.props.hsl.l * 100) + '%' } onChange={ this.handleChange } />
</div>
<div is="field">
<div is="alpha">
<EditableInput is="Input" label="a" value={ this.props.hsl.a } arrowOffset={ .01 } onChange={ this.handleChange } />
</div>
</div>
Expand All @@ -201,7 +210,7 @@ export class ChromeFields extends ReactCSS.Component {
{ fields }
<div is="toggle">
<div is="icon" onClick={ this.toggleViews } ref="icon">
<svg style={{ width:'24px', height:'24px', border: '1px transparent solid', borderRadius: '5px'}}
<svg style={{ width:'24px', height:'24px', border: '1px transparent solid', borderRadius: '5px' }}
viewBox="0 0 24 24"
onMouseOver={ this.showHighlight }
onMouseEnter={ this.showHighlight }
Expand Down
2 changes: 1 addition & 1 deletion src/components/material/Material.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class Material extends ReactCSS.Component {
color: '#333',
padding: '0px',
border: '0px',
borderBottom: '2px solid #' + this.props.hex,
borderBottom: '2px solid ' + this.props.hex,
outline: 'none',
height: '30px',
},
Expand Down
15 changes: 13 additions & 2 deletions src/components/sketched/Sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Sketch extends ReactCSS.Component {
Absolute: '0px 0px 0px 0px',
borderRadius: '2px',
background: 'rgba(' + this.props.rgb.r + ', ' + this.props.rgb.g + ', ' + this.props.rgb.b + ', ' + this.props.rgb.a + ')',
boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)'
boxShadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)',
},
hue: {
position: 'relative',
Expand All @@ -74,6 +74,17 @@ export class Sketch extends ReactCSS.Component {
shadow: 'inset 0 0 0 1px rgba(0,0,0,.15), inset 0 0 4px rgba(0,0,0,.25)',
},
},
'disableAlpha': {
color: {
height: '10px',
},
hue: {
height: '10px',
},
alpha: {
display: 'none',
},
},
}
}

Expand Down Expand Up @@ -102,7 +113,7 @@ export class Sketch extends ReactCSS.Component {
</div>
</div>
<div is="fields">
<SketchFields {...this.props} onChange={ this.handleChange } />
<SketchFields {...this.props} onChange={ this.handleChange } disableAlpha={ this.props.disableAlpha } />
</div>
<div is="presets">
<SketchPresetColors colors={ this.props.presetColors } onClick={ this.handleChange } />
Expand Down
11 changes: 10 additions & 1 deletion src/components/sketched/SketchFields.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ export class ShetchFields extends ReactCSS.Component {
flex: '1',
paddingLeft: '6px',
},
alpha: {
flex: '1',
paddingLeft: '6px',
},
double: {
flex: '2',
},
Expand All @@ -45,6 +49,11 @@ export class ShetchFields extends ReactCSS.Component {
},
},
},
'disableAlpha': {
alpha: {
display: 'none',
},
},
}
}

Expand Down Expand Up @@ -95,7 +104,7 @@ export class ShetchFields extends ReactCSS.Component {
<div is="single">
<EditableInput is="Input" label="b" value={ this.props.rgb.b } onChange={ this.handleChange } dragLabel="true" dragMax="255"/>
</div>
<div is="single">
<div is="alpha">
<EditableInput is="Input" label="a" value={ Math.round(this.props.rgb.a * 100) } onChange={ this.handleChange } dragLabel="true" dragMax="100"/>
</div>
</div>
Expand Down

0 comments on commit 364fd11

Please sign in to comment.