diff --git a/packages/edit-site/src/components/global-styles/screen-color-element.js b/packages/edit-site/src/components/global-styles/screen-color-element.js index 79e7f1c85e66d8..88ab67ed26b46a 100644 --- a/packages/edit-site/src/components/global-styles/screen-color-element.js +++ b/packages/edit-site/src/components/global-styles/screen-color-element.js @@ -16,7 +16,9 @@ import { const elements = { text: { - description: __( '' ), + description: __( + 'Set the default color used for text across the site.' + ), title: __( 'Text' ), }, link: { @@ -44,36 +46,56 @@ function ScreenColorElement( { name, element } ) { const colorsPerOrigin = useColorsPerOrigin( name ); const [ solids ] = useSetting( 'color.palette', name ); const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name ); - const [ isBackgroundEnabled ] = useSetting( 'color.background', name ); + let [ isBackgroundEnabled ] = useSetting( 'color.background', name ); + const [ isTextEnabled ] = useSetting( 'color.text', name ); + + let textColorElementSelector = 'elements.' + element + '.color.text'; + const backgroundColorElementSelector = + 'elements.' + element + '.color.background'; + + let hasElementColor = false; - let hasElementColor = - supports.includes( 'color' ) && - ( solids.length > 0 || areCustomSolidsEnabled ); + switch ( element ) { + case 'button': + hasElementColor = + supports.includes( 'buttonColor' ) && + isBackgroundEnabled && + ( solids.length > 0 || areCustomSolidsEnabled ); + break; + case 'text': + hasElementColor = + supports.includes( 'color' ) && + isTextEnabled && + ( solids.length > 0 || areCustomSolidsEnabled ); + textColorElementSelector = 'color.text'; + isBackgroundEnabled = false; + break; - if ( supports.includes( 'buttonColor' ) ) { - hasElementColor = - supports.includes( 'buttonColor' ) && - isBackgroundEnabled && - ( solids.length > 0 || areCustomSolidsEnabled ); + default: + hasElementColor = + supports.includes( 'color' ) && + ( solids.length > 0 || areCustomSolidsEnabled ); + break; } const [ elementTextColor, setElementTextColor ] = useStyle( - 'elements.' + element + '.color.text', + textColorElementSelector, name ); const [ userElementTextColor ] = useStyle( - 'elements.' + element + '.color.text', + textColorElementSelector, name, 'user' ); const [ elementBgColor, setElementBgColor ] = useStyle( - 'elements.' + element + '.color.background', + backgroundColorElementSelector, name ); + const [ userElementBgColor ] = useStyle( - 'elements.' + element + '.color.background', + backgroundColorElementSelector, name, 'user' ); @@ -103,22 +125,25 @@ function ScreenColorElement( { name, element } ) { onColorChange={ setElementTextColor } clearable={ elementTextColor === userElementTextColor } /> - -