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 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions ui/utilities/visibility/flavors/responsive/_index.scss
Original file line number Diff line number Diff line change
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;
}
}
}
94 changes: 49 additions & 45 deletions ui/utilities/visibility/flavors/responsive/index.markup.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,101 +6,105 @@
<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>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Almost there. Since this is a markdown file, the whitespace between your tr are breaking the overview table.

image

Also, there is a paragraph block above the table that is out of date now. Could you update that as well?

Thanks!

<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
Original file line number Diff line number Diff line change
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>
);