Skip to content

color-palette-panel - add possibility to "group" colors #47837

Open
@Chrico

Description

What problem does this address?

Right now the ColorPalettePanel groups colors via PaletteEdit into the hardcoded 2 groups "Theme" and "Default", but it is not possible to introduce custom grouping. This could become handy when having many custom colors and starting to group them by branding or usage.

Theme

Code: https://github.com/WordPress/gutenberg/blob/v15.0.1/packages/edit-site/src/components/global-styles/color-palette-panel.js#L49-L55

Those are comming from the theme.json via settings.color.palette in following format:

{
    "settings": {
        "color": {
            "palette": [
                {
                    "slug": "primary",
                    "color": "#7c027c",
                    "name": "Purple"
                }
            ]
        }
    }
}

Defaults

Code: https://github.com/WordPress/gutenberg/blob/v15.0.1/packages/edit-site/src/components/global-styles/color-palette-panel.js#L57-L67

Those are default colors which can also be deactivated via theme.json via settings.color.defaultPalette: false

What is your proposed solution?

We could simply extend the settings.color.palette by introducing a new "group"-key to the color settings. This way we were able to add some grouping on the ColorPalettePanel to have better seperation:

{
    "settings": {
        "color": {
            "palette": [
                {
                    "slug": "purple",
                    "color": "#7c027c",
                    "name": "Purple"
                    "group": "Product XYZ Branding"
                },
                {
                    "slug": "lavender",
                    "color": "#E6E6FA",
                    "name": "A different purple"
                    "group": "Product ABC Branding"
                },
                {
                    "slug": "fuchsia",
                    "color": "#FF00FF",
                    "name": "Default purpleish"
                }
            ]
        }
    }
}

The output would looks like following:

We have 3 groups: The 2 custom ones "Product XYZ Branding" and "Product ABC Branding" and additonally the 1 color which has no group defaults to "Theme":

image

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Global StylesAnything related to the broader Global Styles efforts, including Styles Engine and theme.jsonNeeds DesignNeeds design efforts.[Feature] ColorsColor management[Feature] ExtensibilityThe ability to extend blocks or the editing experience[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions