Skip to content

feat (variables): create variable for palette colors#253

Merged
francoistibo merged 1 commit intomasterfrom
feature/palette-colors
Jun 30, 2022
Merged

feat (variables): create variable for palette colors#253
francoistibo merged 1 commit intomasterfrom
feature/palette-colors

Conversation

@firestar300
Copy link
Contributor

Dans cette PR, l'idée est de mettre les couleurs déclarés dans l'éditeur Gutenberg dans une variable SCSS et de lui assigner un nouveau paramètre isColorLight qui pourrait servir à déterminer la bonne couleur du texte à utiliser sur un composant Gutenberg. Exemple sur un composant core/button :

_variables.scss

// ----
// Gutenberg palette
// ----
$palette: (
    "dark": (
        "color": $color-dark,
        "isColorLight": false,
    ),
    "blue": (
        "color": $color-blue-600,
        "isColorLight": false,
    ),
    "grey": (
        "color": #777574,
        "isColorLight": false,
    ),
    "grey-light": (
        "color": #f4f4f4,
        "isColorLight": true,
    ),
    "light": (
        "color": $color-light,
        "isColorLight": true,
    ),
);

_buttons.scss

@use "sass:color";
@use "sass:map";

.wp-block {
    // ----
    // container
    // ----
    &-buttons {
        gap: 25px;
    }

    // ----
    // button
    // ----
    &-button {
        .wp-block-button__link {
            @extend %button-block;

            @each $name, $colors in $palette {
                &.has-#{$name}-background-color {
                    background-color: map.get($colors, color);

                    @if map.get($colors, isColorLight) == true {
                        color: $color-primary !important;
                    } @else {
                        color: $color-light !important;
                    }
                }
            }
        }
    }
}

@francoistibo francoistibo merged commit 7094935 into master Jun 30, 2022
@francoistibo francoistibo deleted the feature/palette-colors branch August 29, 2022 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants