Skip to content
This repository has been archived by the owner on Apr 25, 2019. It is now read-only.

Commit

Permalink
#198 update block utility.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gareth Joyce committed Mar 7, 2017
1 parent 4824d51 commit 73c2295
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 8 deletions.
9 changes: 9 additions & 0 deletions pattern/utility/block/5-position.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php /*
Title: Block top and bottom
Class: .u-block-*
Description: Append -top or -bottom to any block class to add padding to that side only.
*/ ?>

<div class="u-block-xl-top u-fill-neutral-lighter">
<p>Text inside block with only top padding</p>
</div>
44 changes: 36 additions & 8 deletions src/scss/utility/_block.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,53 @@
*/

[class*="u-block"],
%u-block {
%u-block-base {
display: block;

> *:last-child {
margin-bottom: 0;
}
}

[class*="u-block"] > *:last-child,
%u-block > *:last-child {
margin-bottom: 0;
}

@each $key, $value in $spacing {
@if $key == base {
.u-block,
%u-block {
padding: $value;
padding: $value !important;

&-top {
padding-top: $value !important;
}
&-bottom {
padding-bottom: $value !important;
}
}
%u-block {
&,
&-top,
&-bottom {
@extend %u-block-base;
}
}
} @else {
.u-block-#{$key},
%u-block-#{$key} {
padding: $value;
padding: $value !important;

&-top {
padding-top: $value !important;
}
&-bottom {
padding-bottom: $value !important;
}
}
%u-block-#{$key} {
&,
&-top,
&-bottom {
@extend %u-block-base;
}
}
}
}
}

0 comments on commit 73c2295

Please sign in to comment.