Skip to content

Commit

Permalink
feat(utilities): added utilities api (next version will be breaking c…
Browse files Browse the repository at this point in the history
…hange due to removed old utilities)
  • Loading branch information
Dimitri Kopriwa committed Dec 2, 2019
1 parent 2a2f200 commit 52a4c03
Show file tree
Hide file tree
Showing 5 changed files with 4,012 additions and 43 deletions.
86 changes: 43 additions & 43 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,53 +115,53 @@
}
},
"devDependencies": {
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/plugin-external-helpers": "^7.2.0",
"@babel/plugin-proposal-class-properties": "^7.4.4",
"@babel/plugin-proposal-decorators": "^7.4.4",
"@babel/plugin-proposal-json-strings": "^7.2.0",
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
"@babel/plugin-syntax-import-meta": "^7.2.0",
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
"@babel/preset-env": "^7.4.5",
"@babel/cli": "^7.7.4",
"@babel/core": "^7.7.4",
"@babel/plugin-external-helpers": "^7.7.4",
"@babel/plugin-proposal-class-properties": "^7.7.4",
"@babel/plugin-proposal-decorators": "^7.7.4",
"@babel/plugin-proposal-json-strings": "^7.7.4",
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
"@babel/plugin-syntax-import-meta": "^7.7.4",
"@babel/plugin-transform-modules-commonjs": "^7.7.4",
"@babel/preset-env": "^7.7.4",
"@bootstrap-styled/documentation": "^2.0.0",
"@rollup-umd/documentation": "^2.0.5",
"@rollup-umd/documentation": "^2.0.11",
"@rollup-umd/ncu": "^1.0.9",
"@rollup-umd/rollup": "^1.0.13",
"@semantic-release/changelog": "^3.0.4",
"@semantic-release/git": "^7.0.12",
"@semantic-release/github": "^5.4.0",
"@semantic-release/npm": "^5.1.9",
"babel-eslint": "^10.0.2",
"babel-jest": "^24.8.0",
"@rollup-umd/rollup": "^1.1.0",
"@semantic-release/changelog": "^3.0.6",
"@semantic-release/git": "^7.0.18",
"@semantic-release/github": "^5.5.5",
"@semantic-release/npm": "^5.3.4",
"babel-eslint": "^10.0.3",
"babel-jest": "^24.9.0",
"babel-loader": "^8.0.6",
"babel-plugin-add-module-exports": "^1.0.2",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-dynamic-import-node": "^2.2.0",
"cz-conventional-changelog": "^2.1.0",
"babel-plugin-dynamic-import-node": "^2.3.0",
"bootstrap-styled": "^2.6.2",
"cz-conventional-changelog": "^3.0.2",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.14.0",
"eslint": "^5.16.0",
"eslint-config-airbnb": "^17.1.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "^2.17.3",
"eslint-plugin-jsx-a11y": "^6.2.1",
"eslint-plugin-react": "^7.13.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^6.7.2",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-airbnb-base": "^14.0.0",
"eslint-plugin-import": "^2.18.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.17.0",
"immutable": "^4.0.0-rc.12",
"jest-cli": "^24.8.0",
"jest-cli": "^24.9.0",
"jest-sonar-reporter": "^2.0.0",
"lint-staged": "^8.2.1",
"lint-staged": "^9.5.0",
"pre-commit": "^1.2.2",
"react": "^16.8.6",
"react-dom": "^16.8.6",
"react-styleguidist": "^9.1.7",
"rimraf": "^2.6.3",
"rollup": "^1.15.6",
"semantic-release": "^15.13.16",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-styleguidist": "^10.2.1",
"rimraf": "^3.0.0",
"semantic-release": "^15.13.31",
"toctoc": "^0.3.2",
"webpack": "^4.34.0"
"webpack": "^4.41.2"
},
"jest": {
"roots": [
Expand All @@ -188,10 +188,10 @@
],
"coverageThreshold": {
"global": {
"statements": 99,
"branches": 91,
"functions": 99,
"lines": 99
"statements": 80,
"branches": 80,
"functions": 80,
"lines": 80
}
},
"moduleDirectories": [
Expand All @@ -216,8 +216,8 @@
"build:readme"
],
"dependencies": {
"@bootstrap-styled/css-mixins": "^2.0.6",
"@bootstrap-styled/utils": "^1.7.1"
"@bootstrap-styled/css-mixins": "^2.1.1",
"@bootstrap-styled/utils": "^1.8.1"
},
"publishConfig": {
"registry": "https://registry.npmjs.org",
Expand Down
40 changes: 40 additions & 0 deletions src/_api.js
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')}
}`;
}
Loading

0 comments on commit 52a4c03

Please sign in to comment.