Skip to content

Commit

Permalink
Global Styles Color Palette editor default to theme/core paletts.
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Nov 6, 2020
1 parent 5287a71 commit a4e5cef
Showing 1 changed file with 11 additions and 30 deletions.
41 changes: 11 additions & 30 deletions packages/edit-site/src/components/sidebar/color-palette-panel.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,25 @@
/**
* WordPress dependencies
*/
import {
Button,
__experimentalColorEdit as ColorEdit,
} from '@wordpress/components';
import { __experimentalColorEdit as ColorEdit } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

export default function ColorPalettePanel( {
contextName,
getSetting,
setSetting,
} ) {
const colors = getSetting( contextName, 'color.palette' );
let emptyUI;
if ( colors === undefined ) {
emptyUI = __(
'Using theme or core default colors. Add some colors to create your own color palette instead.'
);
} else if ( colors && colors.length === 0 ) {
emptyUI = (
<>
<p>{ __( 'Using an empty color palette.' ) }</p>
<Button
isSmall
isSecondary
onClick={ () => setSetting( contextName, 'color.palette' ) }
>
{ __( 'Reset to theme/core defaults' ) }
</Button>
</>
);
}
/**
* Internal dependencies
*/
import { useEditorFeature } from '../editor/utils';

export default function ColorPalettePanel( { contextName, setSetting } ) {
const colors = useEditorFeature( 'color.palette', contextName );
return (
<ColorEdit
colors={ colors }
onChange={ ( newColors ) => {
setSetting( contextName, 'color.palette', newColors );
} }
emptyUI={ emptyUI }
emptyUI={ __(
'Colors are empty! Add some colors to create your own color palette.'
) }
/>
);
}

0 comments on commit a4e5cef

Please sign in to comment.