Skip to content

Commit

Permalink
Add stylelint rule to prevent theme CSS vars outside of wp-components (
Browse files Browse the repository at this point in the history
…#59020)

* Add stylelint rule to prevent theme CSS vars outside of wp-components

* Fix violations

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: andrewhayward <andrewhayward@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
  • Loading branch information
4 people authored Feb 15, 2024
1 parent f33e8b6 commit 4a28096
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
8 changes: 8 additions & 0 deletions .stylelintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@
"at-rule-empty-line-before": null,
"at-rule-no-unknown": null,
"comment-empty-line-before": null,
"declaration-property-value-disallowed-list": [
{
"/.*/": [ "/--wp-components-color-/" ]
},
{
"message": "--wp-components-color-* variables are not ready to be used outside of the components package."
}
],
"font-weight-notation": null,
"max-line-length": null,
"no-descending-specificity": null,
Expand Down
2 changes: 1 addition & 1 deletion packages/base-styles/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
*/

@mixin block-toolbar-button-style__focus() {
box-shadow: inset 0 0 0 $border-width var(--wp-components-color-background, $white), 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
box-shadow: inset 0 0 0 $border-width $white, 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);

// Windows High Contrast mode will show this outline, but not the box-shadow.
outline: 2px solid transparent;
Expand Down
6 changes: 3 additions & 3 deletions packages/dataviews/src/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
}
th {
text-align: left;
color: var(--wp-components-color-foreground, $gray-900);
color: $gray-900;
font-weight: normal;
font-size: $default-font-size;
}
Expand Down Expand Up @@ -527,7 +527,7 @@
&:hover,
&[data-active-item],
&:focus {
background-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9));
background-color: var(--wp-admin-theme-color);
color: $white;

.dataviews-search-widget-filter-combobox-item-check {
Expand Down Expand Up @@ -587,7 +587,7 @@

&:focus {
background: $white;
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
}

&::placeholder {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
outline: 3px solid transparent;
outline-offset: -2px;

color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
color: var(--wp-admin-theme-color);
background: rgba(var(--wp-admin-theme-color--rgb), 0.04);

.edit-site-global-styles-screen-revisions__revision-button {
Expand All @@ -61,7 +61,7 @@
}

&::before {
background: var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
background: var(--wp-admin-theme-color);
}

.edit-site-global-styles-screen-revisions__changes,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
&:focus-visible:not(:disabled) {
box-shadow:
0 0 0 var(--wp-admin-border-width-focus)
var(--wp-components-color-accent, var(--wp-admin-theme-color, #007cba));
var(--wp-admin-theme-color);
outline: 3px solid transparent;
}

Expand Down

1 comment on commit 4a28096

@github-actions
Copy link

Choose a reason for hiding this comment

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

Flaky tests detected in 4a28096.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7918114805
📝 Reported issues:

Please sign in to comment.