-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started interface to edit caption colors in Global Styles
- Loading branch information
1 parent
74cd9f9
commit cc6fcc4
Showing
5 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
98 changes: 98 additions & 0 deletions
98
packages/edit-site/src/components/global-styles/screen-caption-color.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { __experimentalColorGradientControl as ColorGradientControl } from '@wordpress/block-editor'; | ||
/** | ||
* Internal dependencies | ||
*/ | ||
import ScreenHeader from './header'; | ||
import { | ||
getSupportedGlobalStylesPanels, | ||
useSetting, | ||
useStyle, | ||
useColorsPerOrigin, | ||
} from './hooks'; | ||
|
||
function ScreenCaptionColor( { name } ) { | ||
const supports = getSupportedGlobalStylesPanels( name ); | ||
const colorsPerOrigin = useColorsPerOrigin( name ); | ||
const [ solids ] = useSetting( 'color.palette', name ); | ||
const [ areCustomSolidsEnabled ] = useSetting( 'color.custom', name ); | ||
|
||
const hasCaptionColor = | ||
supports.includes( 'color' ) && | ||
( solids.length > 0 || areCustomSolidsEnabled ); | ||
|
||
const [ captionTextColor, setCaptionTextColor ] = useStyle( | ||
'elements.caption.color.text', | ||
name | ||
); | ||
const [ userCaptionTextColor ] = useStyle( | ||
'elements.caption.color.text', | ||
name, | ||
'user' | ||
); | ||
|
||
const [ captionBgColor, setCaptionBgColor ] = useStyle( | ||
'elements.caption.color.background', | ||
name | ||
); | ||
const [ userCaptionBgColor ] = useStyle( | ||
'elements.caption.color.background', | ||
name, | ||
'user' | ||
); | ||
|
||
if ( ! hasCaptionColor ) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<> | ||
<ScreenHeader | ||
title={ __( 'Captions' ) } | ||
description={ __( | ||
'Set the colors used for captions across the site.' | ||
) } | ||
/> | ||
<div className="edit-site-global-styles-screen-caption-color"> | ||
<h4 className="edit-site-global-styles-section-title"> | ||
{ __( 'Text color' ) } | ||
</h4> | ||
|
||
<ColorGradientControl | ||
className="edit-site-screen-caption-color__control" | ||
colors={ colorsPerOrigin } | ||
disableCustomColors={ ! areCustomSolidsEnabled } | ||
__experimentalHasMultipleOrigins | ||
showTitle={ false } | ||
enableAlpha | ||
__experimentalIsRenderedInSidebar | ||
colorValue={ captionTextColor } | ||
onColorChange={ setCaptionTextColor } | ||
clearable={ captionTextColor === userCaptionTextColor } | ||
/> | ||
|
||
<h4 className="edit-site-global-styles-section-title"> | ||
{ __( 'Background color' ) } | ||
</h4> | ||
|
||
<ColorGradientControl | ||
className="edit-site-screen-caption-color__control" | ||
colors={ colorsPerOrigin } | ||
disableCustomColors={ ! areCustomSolidsEnabled } | ||
__experimentalHasMultipleOrigins | ||
showTitle={ false } | ||
enableAlpha | ||
__experimentalIsRenderedInSidebar | ||
colorValue={ captionBgColor } | ||
onColorChange={ setCaptionBgColor } | ||
clearable={ captionBgColor === userCaptionBgColor } | ||
/> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
export default ScreenCaptionColor; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters