Skip to content

Commit

Permalink
Add: Uneditable duotone palette on the palette gradient panel
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Nov 29, 2021
1 parent fb8a732 commit 8bbfe05
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 5 deletions.
13 changes: 8 additions & 5 deletions packages/components/src/duotone-picker/duotone-picker.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import CustomDuotoneBar from './custom-duotone-bar';
import { getDefaultColors, getGradientFromCSSColors } from './utils';

function DuotonePicker( {
clearable = true,
colorPalette,
duotonePalette,
disableCustomColors,
Expand Down Expand Up @@ -69,11 +70,13 @@ function DuotonePicker( {
);
} ) }
actions={
<CircularOptionPicker.ButtonAction
onClick={ () => onChange( undefined ) }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
!! clearable && (
<CircularOptionPicker.ButtonAction
onClick={ () => onChange( undefined ) }
>
{ __( 'Clear' ) }
</CircularOptionPicker.ButtonAction>
)
}
>
{ ! disableCustomColors && ! disableCustomDuotone && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
/**
* External dependencies
*/
import { noop } from 'lodash';

/**
* WordPress dependencies
*/
import {
__experimentalVStack as VStack,
__experimentalPaletteEdit as PaletteEdit,
DuotonePicker,
__experimentalHeading as Heading,
} from '@wordpress/components';
import { __ } from '@wordpress/i18n';

Expand Down Expand Up @@ -40,11 +47,24 @@ export default function GradientPalettePanel( { name } ) {
'color.defaultGradients',
name
);
const [ duotonePalette ] = useSetting( 'color.duotone' ) || [];
return (
<VStack
className="edit-site-global-styles-gradient-palette-panel"
spacing={ 10 }
>
<div>
<Heading className="edit-site-global-styles-gradient-palette-panel__duotone-heading">
{ __( 'Duotone' ) }
</Heading>
<DuotonePicker
duotonePalette={ duotonePalette }
disableCustomDuotone={ true }
disableCustomColors={ true }
clearable={ false }
onChange={ noop }
/>
</div>
{ !! themeGradients && !! themeGradients.length && (
<PaletteEdit
canReset={ themeGradients !== baseThemeGradients }
Expand Down
8 changes: 8 additions & 0 deletions packages/edit-site/src/components/global-styles/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,11 @@
min-height: $grid-unit-40;
}
}

h2.edit-site-global-styles-gradient-palette-panel__duotone-heading.components-heading {
text-transform: uppercase;
line-height: $grid-unit-30;
font-weight: 500;
font-size: 11px;
margin-bottom: $grid-unit-10;
}

0 comments on commit 8bbfe05

Please sign in to comment.