Skip to content
This repository has been archived by the owner on Dec 5, 2022. It is now read-only.

Commit

Permalink
feat(grid): Add utility classes to hide/show at different breakpoint …
Browse files Browse the repository at this point in the history
…sizes

Close #287
  • Loading branch information
Gabriel Lovato committed Dec 9, 2016
1 parent 915a21e commit a5a875b
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
---
notes: |
Hide/show elements according to breakpoint size. Combine hide and show classes to make elements only appear in a specific range of screen sizes.
---
<div class="dc-row">
<div class="dc-column dc-hide-from-small">
<div class="dc-column__contents ">This element will <strong class="dc-strong">hide</strong> from small breakpoint size on.
</div>
</div>
<div class="dc-column dc-hide-from-medium">
<div class="dc-column__contents ">This element will <strong class="dc-strong">hide</strong> from medium breakpoint size on.
</div>
</div>
<div class="dc-column dc-hide-from-large">
<div class="dc-column__contents ">This element will <strong class="dc-strong">hide</strong> from large breakpoint size on.
</div>
</div>
<div class="dc-column">
<div class="dc-column__contents dc-hide-from-huge">This element will <strong class="dc-strong">hide</strong> from huge breakpoint size on.
</div>
</div>
</div>

<div class="dc-row">
<div class="dc-column dc-show-from-small">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> from small breakpoint size on.
</div>
</div>
<div class="dc-column dc-show-from-medium">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> from medium breakpoint size on.
</div>
</div>
<div class="dc-column dc-show-from-large">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> from large breakpoint size on.
</div>
</div>
<div class="dc-column dc-show-from-huge">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> from large breakpoint size on.
</div>
</div>
</div>

<div class="dc-row">
<div class="dc-column dc-show-from-small dc-hide-from-large">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> in small and medium breakpoint sizes.
</div>
</div>
<div class="dc-column dc-show-from-medium dc-hide-from-huge">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> in medium and large breakpoint sizes.
</div>
</div>
<div class="dc-column dc-show-from-small dc-hide-from-large dc-show-from-huge">
<div class="dc-column__contents">This element will <strong class="dc-strong">show</strong> in small, medium and huge breakpoint sizes.
</div>
</div>

</div>
12 changes: 12 additions & 0 deletions src/styles/structure/_grid-classes.scss
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
// For each breakpoint make the required column and offset classes.
@each $br, $value in $dc-grid-breakpoints {
@include breakpoint(map-get($dc-grid-breakpoints, $br)) {

// Utility classes to hide / show according to breakpoint
// Hide from this breakpoint up
.dc-hide-from-#{$br} {
display: none;
}

.dc-show-from-#{$br} {
display: block;
}

@for $i from 1 through $dc-grid-column-count {
.dc-column--#{$br}-#{$i} {
flex: grid-column-flex($i);
Expand All @@ -140,6 +151,7 @@
.dc-column-offset--#{$br}-#{$o} {
margin-left: grid-column-size($o);
}

}
}
}
Expand Down

0 comments on commit a5a875b

Please sign in to comment.