admin管理员组文章数量:1123950
I've got some colors defined in theme.json- is there a way to define custom sections within the color palette? When I set my own colors, they show up in the section labeled "Theme". The other colors are in a section labeled "Default". [seen below] Is there a way to define new sections here?
Use case: We have a pretty big palette, and I want to split up brand colors (each include a x-light, light, key, dark, and x-dark shade).
Here is my theme.json code:
{
"version": 1,
"settings": {
"color": {
"palette": [
{
"name": "Primary",
"slug": "primary",
"color": "#0EA5E9"
},
{
"name": "Secondary",
"slug": "secondary",
"color": "#14B8A6"
}...
I did a fair bit of Googling but can't seem to land on the right term to unlock the secret. Anyone tried this before?
I've got some colors defined in theme.json- is there a way to define custom sections within the color palette? When I set my own colors, they show up in the section labeled "Theme". The other colors are in a section labeled "Default". [seen below] Is there a way to define new sections here?
Use case: We have a pretty big palette, and I want to split up brand colors (each include a x-light, light, key, dark, and x-dark shade).
Here is my theme.json code:
{
"version": 1,
"settings": {
"color": {
"palette": [
{
"name": "Primary",
"slug": "primary",
"color": "#0EA5E9"
},
{
"name": "Secondary",
"slug": "secondary",
"color": "#14B8A6"
}...
I did a fair bit of Googling but can't seem to land on the right term to unlock the secret. Anyone tried this before?
Share Improve this question asked Sep 20, 2022 at 16:45 clarkclark 5912 silver badges10 bronze badges1 Answer
Reset to default 4No, writing as of Wordpress 6.0 there is no API for defining additional palette sections. The colour palette component hardcodes 3 PaletteEdit
sub-components, theme, default, and custom, where custom is for user defined colours. No dynamic fields or slotfills are provided for extending or adjusting these. Here is the current code:
return (
<VStack
className="edit-site-global-styles-color-palette-panel"
spacing={ 10 }
>
{ !! themeColors && !! themeColors.length && (
<PaletteEdit
canReset={ themeColors !== baseThemeColors }
canOnlyChangeValues
colors={ themeColors }
onChange={ setThemeColors }
paletteLabel={ __( 'Theme' ) }
/>
) }
{ !! defaultColors &&
!! defaultColors.length &&
!! defaultPaletteEnabled && (
<PaletteEdit
canReset={ defaultColors !== baseDefaultColors }
canOnlyChangeValues
colors={ defaultColors }
onChange={ setDefaultColors }
paletteLabel={ __( 'Default' ) }
/>
) }
<PaletteEdit
colors={ customColors }
onChange={ setCustomColors }
paletteLabel={ __( 'Custom' ) }
emptyMessage={ __(
'Custom colors are empty! Add some colors to create your own color palette.'
) }
slugPrefix="custom-"
/>
</VStack>
);
https://github.com/WordPress/gutenberg/blob/a5ef504432e34afc0792eae62e44d71590c031eb/packages/edit-site/src/components/global-styles/color-palette-panel.js
Changing this will require a new API to be added to the block editor. I'd suggest creating an issue on the gutenberg github repo for this if one doesn't already exist.
edit: Still the case in WordPress 6.5
本文标签: Themejson creating different sections of the color palette
版权声明:本文标题:Theme.json: creating different sections of the color palette 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736608692a1945389.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论