Skip to content

Commit

Permalink
Add support for gradient colors
Browse files Browse the repository at this point in the history
  • Loading branch information
oandregal committed Sep 1, 2020
1 parent 26fef81 commit 408abde
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/edit-site/src/components/editor/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
export const FONT_SIZE = 'font-size';
export const LINK_COLOR = '--wp--style--color--link';
export const BACKGROUND_COLOR = 'background-color';
export const GRADIENT_COLOR = 'background';
export const TEXT_COLOR = 'color';
export const LINE_HEIGHT = 'line-height';

Expand All @@ -13,6 +14,7 @@ export const STYLE_PROPS = {
[ LINE_HEIGHT ]: 'typography.lineHeight',
[ TEXT_COLOR ]: 'color.text',
[ BACKGROUND_COLOR ]: 'color.background',
[ GRADIENT_COLOR ]: 'color.gradient',
[ LINK_COLOR ]: 'color.link',
};
export const LINK_COLOR_DECLARATION = `a { color: var(${ LINK_COLOR }, #00e); }`;
Expand Down
5 changes: 4 additions & 1 deletion packages/edit-site/src/components/sidebar/color-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ export default ( {
} );
}

// TODO: do gradients
// TODO: check for gradient support, etc
if ( supports.includes( BACKGROUND_COLOR ) ) {
settings.push( {
colorValue: getProperty( name, 'color', 'background' ),
onColorChange: ( value ) =>
setProperty( name, 'color', 'background', value ),
gradientValue: getProperty( name, 'color', 'gradient' ),
onGradientChange: ( value ) =>
setProperty( name, 'color', 'gradient', value ),
label: __( 'Background color' ),
} );
}
Expand Down

0 comments on commit 408abde

Please sign in to comment.