Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS - Moving to "purpose naming" convention #273

Merged
merged 1 commit into from
Apr 15, 2023

Conversation

erikyo
Copy link
Collaborator

@erikyo erikyo commented Apr 15, 2023

What?

Css custom props were definitely a great innovation and allow you to share the colors of your stylesheet. However, too many plugins end up creating their own color set libraries in the root and you end up with the opposite effect

Why?

IMHO the problem arise because the name of the color is used to set the variable name, and this eventually forces all plugins to create a variable for each color used. This PR makes this plugin follow another method which is to use the names on the purpose that the variables have (and thus success, error etc)
Several articles that talk about this can be found (eg. this or this), it seems to me a very good improvement to do to clean up and simplify the style

How?

:root {
  --wp-notify--color--red: #f00; // Red
  --wp-notify--color--error: var(--wp-notify--color--red);
}

to

$color-red: #d94f4f;
:root {
  --wp-notify--color--error: #{$color-red};
}

@erikyo erikyo requested a review from johnhooks April 15, 2023 18:50
Copy link
Collaborator

@johnhooks johnhooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. Eventually it would be nice if we could import the same colors used by Gutenberg.

@erikyo erikyo merged commit 4ab48f8 into WordPress:develop Apr 15, 2023
@erikyo erikyo deleted the style/purpose-naming branch April 15, 2023 19:46
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.

2 participants