Skip to content

Commit

Permalink
Feedback application
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Oct 15, 2021
1 parent 5240a49 commit 8706c2d
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 14 deletions.
1 change: 1 addition & 0 deletions packages/components/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
### Breaking Changes

- The `color` property a `tinycolor2` color object passed on `onChangeComplete` property of the `ColorPicker` component was removed. Please use the new `onChange` property that accepts a string color representation ([#35562](https://github.com/WordPress/gutenberg/pull/35562)).

## 18.0.0 (2021-10-12)

### Breaking Changes
Expand Down
6 changes: 1 addition & 5 deletions packages/components/src/color-picker/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,7 @@ const ColorPicker = (

const handleChange = useCallback(
( nextValue: Colord ) => {
debouncedSetColor(
nextValue.alpha() < 1
? nextValue.toRgbString()
: nextValue.toHex()
);
debouncedSetColor( nextValue.toHex() );
},
[ debouncedSetColor ]
);
Expand Down
4 changes: 1 addition & 3 deletions packages/components/src/color-picker/hex-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => {
}
};

const value = color.toHex();

return (
<ColorHexInputControl
prefix={
Expand All @@ -43,7 +41,7 @@ export const HexInput = ( { color, onChange, enableAlpha }: HexInputProps ) => {
#
</Spacer>
}
value={ value.slice( 1 ).toUpperCase() }
value={ color.toHex().slice( 1 ).toUpperCase() }
onChange={ ( nextValue ) => {
onChange( colord( '#' + nextValue ) );
} }
Expand Down
5 changes: 1 addition & 4 deletions packages/components/src/color-picker/stories/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
* External dependencies
*/
import { boolean, select } from '@storybook/addon-knobs';
import { colord } from 'colord';

/**
* WordPress dependencies
Expand Down Expand Up @@ -48,9 +47,7 @@ const Example = () => {
marginTop={ space( 10 ) }
>
<ColorPicker { ...props } color={ color } onChange={ setColor } />
<div style={ { width: 200, textAlign: 'center' } }>
{ colord( color ).toHslString() }
</div>
<div style={ { width: 200, textAlign: 'center' } }>{ color }</div>
<ColorPicker { ...props } color={ color } onChange={ setColor } />
</Flex>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/components/src/color-picker/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ describe( 'ColorPicker', () => {
await sleep( 1 );

expect( onChange ).toHaveBeenCalledWith(
expect.stringContaining( 'rgba' )
expect.stringMatching( /^#([a-fA-F0-9]{8})$/ )
);
} );

Expand Down Expand Up @@ -154,7 +154,7 @@ describe( 'ColorPicker', () => {
await sleep( 1 );

expect( onChange ).toHaveBeenCalledWith(
expect.stringContaining( '#' )
expect.stringMatching( /^#([a-fA-F0-9]{6})$/ )
);
} );
} );

0 comments on commit 8706c2d

Please sign in to comment.