我已经在主题中定义了一些颜色。some有办法在调色板中定义自定义部分吗?当我设置自己的颜色时,它们会出现在标有“主题”的部分。其他颜色在标记为“默认”的部分中。见下这里有定义新章节的方法吗?

用例:我们有一个相当大的调色板,我想分拆品牌颜色(每种颜色包括x光、光、键、暗和x暗色调)。
以下是我的theme.json代码:
{
"version": 1,
"settings": {
"color": {
"palette": [
{
"name": "Primary",
"slug": "primary",
"color": "#0EA5E9"
},
{
"name": "Secondary",
"slug": "secondary",
"color": "#14B8A6"
}...我做了一些谷歌搜索,但似乎无法在正确的条件下解开这个秘密。以前有人试过吗?
发布于 2022-09-20 17:01:03
不,编写Wordpress 6.0时没有用于定义额外调色板部分的API。调色板组件硬编码3个PaletteEdit子组件,主题,默认和自定义,其中自定义是为用户定义的颜色。没有提供动态字段或槽填充来扩展或调整这些字段。以下是当前代码:
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>
);要改变这一点,需要向块编辑器添加一个新的API。如果还不存在,我建议在gutenberg github回购上创建一个问题。
https://wordpress.stackexchange.com/questions/409676
复制相似问题