Skip to content

Commit

Permalink
Update ColorPalette component to accept disableAlpha parameter (#18175)
Browse files Browse the repository at this point in the history
* Add disableAlpha parameter to ColorPalette

Adds the disableAlpha parameter to ColorPalette component which is
passed forward to the ColorPicker to show. Previously it was set to true
by default. Fixes #4726

* Update documentation with disableAlpha parameter
  • Loading branch information
mkaz committed Oct 30, 2019
1 parent 2ce17a8 commit 96f7d34
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
8 changes: 8 additions & 0 deletions packages/components/src/color-palette/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ Whether the palette should have a clearing button or not.
- Required: No
- Default: true

### disableAlpha

Whether to disable alpha channel controls or not.

- Type: `Boolean`
- Required: No
- Default: true


## Usage
```jsx
Expand Down
3 changes: 2 additions & 1 deletion packages/components/src/color-palette/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function ColorPalette( {
clearable = true,
className,
colors,
disableAlpha = true,
disableCustomColors = false,
onChange,
value,
Expand Down Expand Up @@ -55,7 +56,7 @@ export default function ColorPalette( {
<ColorPicker
color={ value }
onChangeComplete={ ( color ) => onChange( color.hex ) }
disableAlpha
disableAlpha={ disableAlpha }
/>
),
[ value ]
Expand Down
14 changes: 14 additions & 0 deletions packages/components/src/color-palette/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,17 @@ export const withKnobs = () => {
);
};

export const withAlpha = () => {
const colors = [
object( 'Red', { name: 'red', color: '#f00' } ),
object( 'White', { name: 'white', color: '#fff' } ),
object( 'Blue', { name: 'blue', color: '#00f' } ),
];

return (
<ColorPaletteWithState
colors={ colors }
disableAlpha={ false }
/>
);
};

0 comments on commit 96f7d34

Please sign in to comment.