-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(HelperClasses): add breakpoint helper classes
- Loading branch information
Showing
3 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
packages/react/src/components/Helpers/HelperClasses.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Copyright IBM Corp. 2016, 2018 | ||
* | ||
* This source code is licensed under the Apache-2.0 license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
/* eslint-disable no-console */ | ||
|
||
import React from 'react'; | ||
import { usePrefix } from '../../internal/usePrefix'; | ||
|
||
export default { | ||
title: 'Helpers/BreakpointClasses', | ||
component: BreakpointClasses, | ||
}; | ||
|
||
export const BreakpointClasses = () => { | ||
const prefix = usePrefix(); | ||
return ( | ||
<> | ||
<div className={`${prefix}__hidden--sm-only`}>Small Only</div> | ||
<div className={`${prefix}__hidden--md-only`}>Medium Only</div> | ||
<div className={`${prefix}__hidden--lg-only`}>Large Only</div> | ||
<div className={`${prefix}__hidden--xlg-only`}>XL Only</div> | ||
<div className={`${prefix}__hidden--max-only`}>Max Only</div> | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
@use '../breakpoint' as *; | ||
@use '../config'; | ||
|
||
div[class*='hidden--'] { | ||
padding: 2rem 1rem; | ||
} | ||
|
||
// Classes that are used to hide elements only at specific breakpoints. | ||
// Helpful for when you would like to hide elements outside of a Grid | ||
.#{config.$prefix}__hidden--sm-only { | ||
background: #8a3ffc; | ||
@include breakpoint-between('sm', 'md') { | ||
display: none; | ||
} | ||
} | ||
|
||
.#{config.$prefix}__hidden--md-only { | ||
background: #4589ff; | ||
@include breakpoint-between('md', 'lg') { | ||
display: none; | ||
} | ||
} | ||
|
||
.#{config.$prefix}__hidden--lg-only { | ||
background: #42be65; | ||
@include breakpoint-between('lg', 'xlg') { | ||
display: none; | ||
} | ||
} | ||
|
||
.#{config.$prefix}__hidden--xlg-only { | ||
background: #f1c21b; | ||
@include breakpoint-between('xlg', 'max') { | ||
display: none; | ||
} | ||
} | ||
|
||
.#{config.$prefix}__hidden--max-only { | ||
background: #da1e28; | ||
@include breakpoint-up('max') { | ||
display: none; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters