Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Improved Visibility styles for responsive design #429

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
29 changes: 29 additions & 0 deletions ui/utilities/visibility/flavors/responsive/_index.scss
Expand Up @@ -13,3 +13,32 @@
@include visibility(small, $mq-small, $mq-medium);
@include visibility(medium, $mq-medium, $mq-large);
@include visibility(large, $mq-large);

// Generates responsive visibility tags
@each $key, $value in (
'x-small': $mq-x-small,
'small': $mq-small,
'medium': $mq-medium,
'large': $mq-large,
'x-large': $mq-x-large,
) {
@media(min-width: $value) {
// [EXAMPLE] slds-hide--medium:
// HIDES the element when window is BIGGER than medium.
// element will be displayed normaly when window is smaller.
.slds-hide--#{$key} {
// !important is required to increase specificity
display: none !important;
}
}

@media(max-width: $value - 1px) {
// [EXAMPLE] slds-show--medium:
// HIDES the element when window is SMALLER than medium.
// element will be displayed normaly when window is bigger.
.slds-show--#{$key} {
// !important is required to increase specificity
display: none !important;
}
}
}
95 changes: 49 additions & 46 deletions ui/utilities/visibility/flavors/responsive/index.markup.md
@@ -1,106 +1,109 @@
<p>Responsive visibility classes will show and hide content on specific breakpoints. By default, <code>-show</code> renders as <code>display: block;</code>, but you may pass through a display property of your choice by adding a modifier to the end of the classname. For example, you may need to render an element as <code>display: inline-block</code> at a medium breakpoint, adding <code>--inline-block</code> to the end of <code>.slds-medium-show</code> to produce the class of <code>.slds-medium-show--inline-block</code> will give you that outcome.</p>
<p>Responsive visibility classes will HIDE content on specific breakpoints.
<code>slds-show--[breakpoint]</code> renders <code>display: none;</code> when the the view port width is smaller than the breakpoint, and do nothing if it is bigger or equal.
<code>slds-hide--[breakpoint]</code> does the oposite by rendering <code>display: none;</code> when the the view port width is bigger or equal than the breakpoint, and do nothing if it is smaller.
</p>

<div class="demo-visibility-chart slds-m-bottom--large">
<div class="slds-scrollable--x">
<table class="slds-table slds-table--bordered slds-no-row-hover">
<tr class="site-text-heading--label">
<th scope="col"><span class="slds-assistive-text">Class Name</span></th>
<th scope="col">Less than 320px</th>
<th scope="col">X-Small (320px)</th>
<th scope="col">Small (480px)</th>
<th scope="col">Medium (768px)</th>
<th scope="col">Large (1024px)</th>
<th scope="col">Greater than 1024px</th>
<th scope="col">X-Small (>= 320px)</th>
<th scope="col">Small (>= 480px)</th>
<th scope="col">Medium (>= 768px)</th>
<th scope="col">Large (>= 1024px)</th>
<th scope="col">X-Large (>= 1280px)</th>
</tr>
<tr>
<th><code>.slds-x-small-show</code></th>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<th><code>.slds-hide--x-small</code></th>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
</tr>
<tr>
<th><code>.slds-small-show</code></th>
<td class="hidden">Hide</td>
<th><code>.slds-show--x-small</code></th>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
</tr>
<tr>
<th><code>.slds-medium-show</code></th>
<th><code>.slds-hide--small</code></th>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
</tr>
<tr>
<th><code>.slds-large-show</code></th>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<th><code>.slds-show--small</code></th>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
</tr>
<tr>
<th><code>.slds-x-small-show-only</code></th>
<td class="hidden">Hide</td>
<th><code>.slds-hide--medium</code></th>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
</tr>
<tr>
<th><code>.slds-small-show-only</code></th>
<th><code>.slds-show--medium</code></th>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
</tr>
<tr>
<th><code>.slds-hide--large</code></th>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
</tr>
<tr>
<th><code>.slds-medium-show-only</code></th>
<th><code>.slds-show--large</code></th>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
</tr>
<tr>
<th><code>.slds-max-x-small-hide</code></th>
<th><code>.slds-hide--x-large</code></th>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="visible">Show</td>
<td class="hidden">Hide</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
</tr>
<tr>
<th><code>.slds-max-small-hide</code></th>
<th><code>.slds-show--x-large</code></th>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
</tr>
<tr>
<th><code>.slds-max-medium-hide</code></th>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="hidden">Hide</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Initial</td>
<td class="visible">Show</td>
</tr>
</table>
</div>
Expand Down
21 changes: 11 additions & 10 deletions ui/utilities/visibility/flavors/responsive/index.react.example.jsx
Expand Up @@ -15,18 +15,19 @@ import CodeClass from 'app_modules/site/components/code-class';

export default (
<div className="demo-only demo-visibility">
<div className="slds-x-small-show">Show on 320px and up</div>
<div className="slds-x-small-show-only">Show only between 320px and 479px</div>
<div className="slds-max-x-small-hide">Hide on 319px and down</div>
<div className="slds-show--x-small">Hides on 319px and down</div>
<div className="slds-hide--x-small">Hides on 320px and up</div>

<div className="slds-small-show">Show on 480px and up</div>
<div className="slds-small-show-only">Show only between 480px and 767px</div>
<div className="slds-max-small-hide">Hide on 479px and down</div>
<div className="slds-show--small">Hides on 479px and down</div>
<div className="slds-hide--small">Hides on 480px and up</div>

<div className="slds-medium-show">Show on 768px and up</div>
<div className="slds-medium-show-only">Show only between 768px and 1023px</div>
<div className="slds-max-medium-hide">Hide on 1023px and down</div>
<div className="slds-show--medium">Hides on 767px and down</div>
<div className="slds-hide--medium">Hides on 768px and up</div>

<div className="slds-large-show">Show on 1024px and up</div>
<div className="slds-show--large">Hides on 1023px and down</div>
<div className="slds-hide--large">Hides on 1024px and up</div>

<div className="slds-show--x-large">Hides on 1279px and down</div>
<div className="slds-hide--x-large">Hides on 1280px and up</div>
</div>
);