Przeglądaj źródła

Seedlet: Make spacing overrides more specific

Jack Lenox 4 lat temu
rodzic
commit
cb28d0b69c

+ 17 - 8
seedlet/assets/css/style-editor.css

@@ -534,6 +534,23 @@ div[data-type="core/button"] {
 	margin-bottom: inherit;
 }
 
+.wp-block-cover > .wp-block-column > *:first-child,
+.wp-block-cover-image > .wp-block-column > *:first-child {
+	margin-top: 0;
+}
+
+.wp-block-cover > .wp-block-column > *:last-child:not(.block-list-appender),
+.wp-block-cover-image > .wp-block-column > *:last-child:not(.block-list-appender) {
+	margin-bottom: 0;
+}
+
+.wp-block-cover.has-child-selected > .wp-block-column > *:nth-last-child(2),
+.wp-block-cover.is-selected > .wp-block-column > *:nth-last-child(2),
+.wp-block-cover-image.has-child-selected > .wp-block-column > *:nth-last-child(2),
+.wp-block-cover-image.is-selected > .wp-block-column > *:nth-last-child(2) {
+	margin-bottom: 0;
+}
+
 .wp-block-cover .wp-block-cover__inner-container,
 .wp-block-cover .wp-block-cover-image-text,
 .wp-block-cover .wp-block-cover-text,
@@ -1506,14 +1523,6 @@ pre.wp-block-verse {
 	margin-bottom: var(--global--spacing-vertical);
 }
 
-[data-block] [data-block]:first-child {
-	margin-top: 0;
-}
-
-[data-block] [data-block]:nth-last-child(2) {
-	margin-bottom: 0;
-}
-
 /*
  * Custom gradients
 */

+ 20 - 0
seedlet/assets/sass/abstracts/_mixins.scss

@@ -113,3 +113,23 @@
 		 }
 	 }
  }
+
+ @mixin innerblock-margin-clear($container) {
+
+	 // Clear the top margin for the first-child.
+	 > #{$container} > *:first-child {
+		 margin-top: 0;
+	 }
+
+	 // Last child that is not the appender.
+	 > #{$container} > *:last-child:not(.block-list-appender) {
+		 margin-bottom: 0;
+	 }
+
+	 // When selected, the last item becomes the second last because of the appender.
+	 &.has-child-selected > #{$container} > *:nth-last-child(2),
+	 &.is-selected > #{$container} > *:nth-last-child(2) {
+		 margin-bottom: 0;
+	 }
+
+ }

+ 2 - 0
seedlet/assets/sass/blocks/cover/_editor.scss

@@ -6,6 +6,8 @@
 	margin-top: inherit;
 	margin-bottom: inherit;
 
+	@include innerblock-margin-clear(".wp-block-column");
+
 	.wp-block-cover__inner-container,
 	.wp-block-cover-image-text,
 	.wp-block-cover-text,

+ 0 - 9
seedlet/assets/sass/blocks/utilities/_editor.scss

@@ -149,15 +149,6 @@
 [data-block] {
 	margin-top: var(--global--spacing-vertical);
 	margin-bottom: var(--global--spacing-vertical);
-
-	[data-block]:first-child {
-		margin-top: 0;
-	}
-
-	// Needs to be the second-last child to avoid applying this to the appender.
-	[data-block]:nth-last-child(2) {
-		margin-bottom: 0;
-	}
 }
 
 /*