-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(utilities): added utilities api (next version will be breaking c…
…hange due to removed old utilities)
- Loading branch information
Dimitri Kopriwa
committed
Dec 2, 2019
1 parent
2a2f200
commit 52a4c03
Showing
5 changed files
with
4,012 additions
and
43 deletions.
There are no files selected for viewing
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
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,40 @@ | ||
import { mediaBreakpointUp, breakpointInfix } from '@bootstrap-styled/css-mixins/lib/breakpoints'; | ||
import { generateUtility } from '@bootstrap-styled/css-mixins/lib/utilities'; | ||
|
||
/** | ||
* @param {object} gridBreakpoints - grid breakpoints | ||
* @param {Map} utilities - map of utilities | ||
* @returns {string} - css screen utilities | ||
*/ | ||
export function screenUtilities( | ||
gridBreakpoints, | ||
utilities, | ||
) { | ||
return Object.keys(gridBreakpoints).map((bp) => { | ||
const infix = breakpointInfix(bp, gridBreakpoints); | ||
const utilityList = []; | ||
// eslint-disable-next-line no-unused-vars, no-restricted-syntax | ||
for (const [key, utility] of utilities) { | ||
if (utility && (utility.responsive || infix === '')) { | ||
utilityList.push(generateUtility(utility, infix)); | ||
} | ||
} | ||
return mediaBreakpointUp(bp, gridBreakpoints, utilityList.join('\n')); | ||
}).join('\n'); | ||
} | ||
|
||
export function printUtilities( | ||
gridBreakpoints, | ||
utilities, | ||
) { | ||
const utilityList = []; | ||
// eslint-disable-next-line no-unused-vars, no-restricted-syntax | ||
for (const [key, utility] of utilities) { | ||
if (utility && utility.print === true) { | ||
utilityList.push(generateUtility(utility, '-print')); | ||
} | ||
} | ||
return `@media print { | ||
${utilityList.join('\n')} | ||
}`; | ||
} |
Oops, something went wrong.