From f2cb2e8d77a98d8f923d38b7ae1079ebafc8b13c Mon Sep 17 00:00:00 2001 From: jasmussen Date: Mon, 14 Jun 2021 12:37:24 +0200 Subject: [PATCH 1/2] Try: Reduce specificity of reset & classic styles. --- packages/block-library/src/reset.scss | 4 +++- packages/edit-post/src/classic.scss | 20 +++++++++++++++----- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/packages/block-library/src/reset.scss b/packages/block-library/src/reset.scss index deaa6774abcc9..06199037876c5 100644 --- a/packages/block-library/src/reset.scss +++ b/packages/block-library/src/reset.scss @@ -5,7 +5,9 @@ * of the editor by themes. */ -.editor-styles-wrapper { +// We use :where to keep specificity minimal. +// https://css-tricks.com/almanac/selectors/w/where/ +html :where(.editor-styles-wrapper) { padding: 8px; /** diff --git a/packages/edit-post/src/classic.scss b/packages/edit-post/src/classic.scss index a58b9b07052b9..f68352b6b447f 100644 --- a/packages/edit-post/src/classic.scss +++ b/packages/edit-post/src/classic.scss @@ -1,12 +1,22 @@ -// This needs specificity to override the editor styles. -.editor-styles-wrapper .wp-block { +// We use :where to keep specificity minimal. +// https://css-tricks.com/almanac/selectors/w/where/ +// Provide baseline auto margin for centering blocks. +.editor-styles-wrapper :where(.wp-block) { margin-left: auto; margin-right: auto; } -// Depreacted style needed for the block widths and alignments. -// for themes that don't support the new layout (theme.json) -.wp-block { +// This needs specificity to override theme editor styles +// such as ol { margin-left: 0; }. +.editor-styles-wrapper ol.wp-block, +.editor-styles-wrapper ul.wp-block { + margin-left: auto; + margin-right: auto; +} + +// Deprecated style needed for the block widths and alignments. +// for themes that don't support the new layout (theme.json). +html :where(.wp-block) { max-width: $content-width; // Provide every block with a default base margin. This margin provides a consistent spacing From 54b45323063327c27f1aec488775d0f221fcdaab Mon Sep 17 00:00:00 2001 From: jasmussen Date: Thu, 5 Aug 2021 12:17:35 +0200 Subject: [PATCH 2/2] Restore specificity of classic auto margin rule. --- packages/edit-post/src/classic.scss | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/packages/edit-post/src/classic.scss b/packages/edit-post/src/classic.scss index f68352b6b447f..cf3a016d38f6b 100644 --- a/packages/edit-post/src/classic.scss +++ b/packages/edit-post/src/classic.scss @@ -1,15 +1,7 @@ -// We use :where to keep specificity minimal. -// https://css-tricks.com/almanac/selectors/w/where/ // Provide baseline auto margin for centering blocks. -.editor-styles-wrapper :where(.wp-block) { - margin-left: auto; - margin-right: auto; -} - -// This needs specificity to override theme editor styles -// such as ol { margin-left: 0; }. -.editor-styles-wrapper ol.wp-block, -.editor-styles-wrapper ul.wp-block { +// Specificity is kept at this level as many classic themes output +// rules like figure { margin: 0; } which would break centering. +.editor-styles-wrapper .wp-block { margin-left: auto; margin-right: auto; }