From 0ba0494a24fd027bf63fa3bffc53f77f7e08d23b Mon Sep 17 00:00:00 2001 From: Ella Date: Tue, 14 May 2024 18:21:21 +0900 Subject: [PATCH] Don't add :root :where for single classes, because they are already 0-1-0 specificity --- packages/block-library/src/audio/theme.scss | 2 +- packages/block-library/src/cover/style.scss | 8 ++------ packages/block-library/src/embed/theme.scss | 2 +- packages/block-library/src/gallery/editor.scss | 3 +++ packages/block-library/src/image/theme.scss | 2 +- packages/block-library/src/pullquote/theme.scss | 4 +--- packages/block-library/src/quote/theme.scss | 2 +- packages/block-library/src/social-links/style.scss | 2 +- packages/block-library/src/table/theme.scss | 6 ++---- packages/block-library/src/template-part/theme.scss | 12 +++++------- packages/block-library/src/video/theme.scss | 2 +- 11 files changed, 19 insertions(+), 26 deletions(-) diff --git a/packages/block-library/src/audio/theme.scss b/packages/block-library/src/audio/theme.scss index ef0520dbce0b21..2744d36e74ca62 100644 --- a/packages/block-library/src/audio/theme.scss +++ b/packages/block-library/src/audio/theme.scss @@ -2,6 +2,6 @@ @include caption-style-theme(); } -:root :where(.wp-block-audio) { +.wp-block-audio { margin: 0 0 1em 0; } diff --git a/packages/block-library/src/cover/style.scss b/packages/block-library/src/cover/style.scss index 7155101ae7c319..b190953f38a6d1 100644 --- a/packages/block-library/src/cover/style.scss +++ b/packages/block-library/src/cover/style.scss @@ -1,11 +1,7 @@ -// Lowest specificity styles are used to ensure that the default styles for the cover block can be overridden by global styles. -:root :where(.wp-block-cover-image, .wp-block-cover) { - min-height: 430px; - padding: 1em; -} - .wp-block-cover-image, .wp-block-cover { + min-height: 430px; + padding: 1em; position: relative; background-position: center center; display: flex; diff --git a/packages/block-library/src/embed/theme.scss b/packages/block-library/src/embed/theme.scss index 92d4f0566b1a3c..e809a783b9c810 100644 --- a/packages/block-library/src/embed/theme.scss +++ b/packages/block-library/src/embed/theme.scss @@ -2,6 +2,6 @@ @include caption-style-theme(); } -:root :where(.wp-block-embed) { +.wp-block-embed { margin: 0 0 1em 0; } diff --git a/packages/block-library/src/gallery/editor.scss b/packages/block-library/src/gallery/editor.scss index ece76a6f86890f..9efaf88e5acc71 100644 --- a/packages/block-library/src/gallery/editor.scss +++ b/packages/block-library/src/gallery/editor.scss @@ -1,3 +1,6 @@ +// Adding `figure` to the selector increases the specificity above the global +// styles specificity, which is levelled at 0-1-0. We should figure out why +// `figure` is needed. :root :where(figure.wp-block-gallery) { // Override the default list style type _only in the editor_ // to avoid :not() selector specificity issues. diff --git a/packages/block-library/src/image/theme.scss b/packages/block-library/src/image/theme.scss index 096a8374a91f6a..d5b2cfb0e83e94 100644 --- a/packages/block-library/src/image/theme.scss +++ b/packages/block-library/src/image/theme.scss @@ -2,6 +2,6 @@ @include caption-style-theme(); } -:root :where(.wp-block-image) { +.wp-block-image { margin: 0 0 1em 0; } diff --git a/packages/block-library/src/pullquote/theme.scss b/packages/block-library/src/pullquote/theme.scss index 5ef3f5a636cd1f..6b5e8401227f5b 100644 --- a/packages/block-library/src/pullquote/theme.scss +++ b/packages/block-library/src/pullquote/theme.scss @@ -1,11 +1,9 @@ -:root :where(.wp-block-pullquote) { +.wp-block-pullquote { border-top: 4px solid currentColor; border-bottom: 4px solid currentColor; margin-bottom: 1.75em; color: currentColor; -} -.wp-block-pullquote { cite, footer, &__citation { diff --git a/packages/block-library/src/quote/theme.scss b/packages/block-library/src/quote/theme.scss index 903628c280cd05..5bcccbd60eefc4 100644 --- a/packages/block-library/src/quote/theme.scss +++ b/packages/block-library/src/quote/theme.scss @@ -1,4 +1,4 @@ -:root :where(.wp-block-quote) { +.wp-block-quote { border-left: 0.25em solid currentColor; margin: 0 0 1.75em 0; padding-left: 1em; diff --git a/packages/block-library/src/social-links/style.scss b/packages/block-library/src/social-links/style.scss index 50e299fd96226e..1ad883bbb88840 100644 --- a/packages/block-library/src/social-links/style.scss +++ b/packages/block-library/src/social-links/style.scss @@ -1,4 +1,4 @@ -:root :where(.wp-block-social-links) { +.wp-block-social-links { // This block has customizable padding, border-box makes that more predictable. box-sizing: border-box; diff --git a/packages/block-library/src/table/theme.scss b/packages/block-library/src/table/theme.scss index e6a5477dce8195..d42e79b02b4965 100644 --- a/packages/block-library/src/table/theme.scss +++ b/packages/block-library/src/table/theme.scss @@ -1,4 +1,6 @@ .wp-block-table { + margin: 0 0 1em 0; + td, th { word-break: normal; @@ -8,7 +10,3 @@ @include caption-style-theme(); } } - -:root :where(.wp-block-table) { - margin: 0 0 1em 0; -} diff --git a/packages/block-library/src/template-part/theme.scss b/packages/block-library/src/template-part/theme.scss index fd503bbe9b8a4e..179873b9448b82 100644 --- a/packages/block-library/src/template-part/theme.scss +++ b/packages/block-library/src/template-part/theme.scss @@ -1,9 +1,7 @@ // Same as the group block styles. -:root :where(.wp-block-template-part) { - &.has-background { - // Matches paragraph Block padding - padding: $block-bg-padding--v $block-bg-padding--h; - margin-top: 0; - margin-bottom: 0; - } +:root :where(.wp-block-template-part.has-background) { + // Matches paragraph Block padding + padding: $block-bg-padding--v $block-bg-padding--h; + margin-top: 0; + margin-bottom: 0; } diff --git a/packages/block-library/src/video/theme.scss b/packages/block-library/src/video/theme.scss index 84d50a76bcc145..cdc95af0b02c29 100644 --- a/packages/block-library/src/video/theme.scss +++ b/packages/block-library/src/video/theme.scss @@ -2,6 +2,6 @@ @include caption-style-theme(); } -:root :where(.wp-block-video) { +.wp-block-video { margin: 0 0 1em 0; }