Skip to content

Commit 9ba511e

Browse files
authored
Merge pull request #49 from bootstrap-styled/dev
feat(utilities): added utilities api (next version will be breaking c…
2 parents 3fe4db6 + 52a4c03 commit 9ba511e

File tree

5 files changed

+4012
-43
lines changed

5 files changed

+4012
-43
lines changed

package.json

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -115,53 +115,53 @@
115115
}
116116
},
117117
"devDependencies": {
118-
"@babel/cli": "^7.4.4",
119-
"@babel/core": "^7.4.5",
120-
"@babel/plugin-external-helpers": "^7.2.0",
121-
"@babel/plugin-proposal-class-properties": "^7.4.4",
122-
"@babel/plugin-proposal-decorators": "^7.4.4",
123-
"@babel/plugin-proposal-json-strings": "^7.2.0",
124-
"@babel/plugin-proposal-object-rest-spread": "^7.4.4",
125-
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
126-
"@babel/plugin-syntax-import-meta": "^7.2.0",
127-
"@babel/plugin-transform-modules-commonjs": "^7.4.4",
128-
"@babel/preset-env": "^7.4.5",
118+
"@babel/cli": "^7.7.4",
119+
"@babel/core": "^7.7.4",
120+
"@babel/plugin-external-helpers": "^7.7.4",
121+
"@babel/plugin-proposal-class-properties": "^7.7.4",
122+
"@babel/plugin-proposal-decorators": "^7.7.4",
123+
"@babel/plugin-proposal-json-strings": "^7.7.4",
124+
"@babel/plugin-proposal-object-rest-spread": "^7.7.4",
125+
"@babel/plugin-syntax-dynamic-import": "^7.7.4",
126+
"@babel/plugin-syntax-import-meta": "^7.7.4",
127+
"@babel/plugin-transform-modules-commonjs": "^7.7.4",
128+
"@babel/preset-env": "^7.7.4",
129129
"@bootstrap-styled/documentation": "^2.0.0",
130-
"@rollup-umd/documentation": "^2.0.5",
130+
"@rollup-umd/documentation": "^2.0.11",
131131
"@rollup-umd/ncu": "^1.0.9",
132-
"@rollup-umd/rollup": "^1.0.13",
133-
"@semantic-release/changelog": "^3.0.4",
134-
"@semantic-release/git": "^7.0.12",
135-
"@semantic-release/github": "^5.4.0",
136-
"@semantic-release/npm": "^5.1.9",
137-
"babel-eslint": "^10.0.2",
138-
"babel-jest": "^24.8.0",
132+
"@rollup-umd/rollup": "^1.1.0",
133+
"@semantic-release/changelog": "^3.0.6",
134+
"@semantic-release/git": "^7.0.18",
135+
"@semantic-release/github": "^5.5.5",
136+
"@semantic-release/npm": "^5.3.4",
137+
"babel-eslint": "^10.0.3",
138+
"babel-jest": "^24.9.0",
139139
"babel-loader": "^8.0.6",
140140
"babel-plugin-add-module-exports": "^1.0.2",
141141
"babel-plugin-array-includes": "^2.0.3",
142-
"babel-plugin-dynamic-import-node": "^2.2.0",
143-
"cz-conventional-changelog": "^2.1.0",
142+
"babel-plugin-dynamic-import-node": "^2.3.0",
143+
"bootstrap-styled": "^2.6.2",
144+
"cz-conventional-changelog": "^3.0.2",
144145
"enzyme": "^3.10.0",
145-
"enzyme-adapter-react-16": "^1.14.0",
146-
"eslint": "^5.16.0",
147-
"eslint-config-airbnb": "^17.1.0",
148-
"eslint-config-airbnb-base": "^13.1.0",
149-
"eslint-plugin-import": "^2.17.3",
150-
"eslint-plugin-jsx-a11y": "^6.2.1",
151-
"eslint-plugin-react": "^7.13.0",
146+
"enzyme-adapter-react-16": "^1.15.1",
147+
"eslint": "^6.7.2",
148+
"eslint-config-airbnb": "^18.0.1",
149+
"eslint-config-airbnb-base": "^14.0.0",
150+
"eslint-plugin-import": "^2.18.2",
151+
"eslint-plugin-jsx-a11y": "^6.2.3",
152+
"eslint-plugin-react": "^7.17.0",
152153
"immutable": "^4.0.0-rc.12",
153-
"jest-cli": "^24.8.0",
154+
"jest-cli": "^24.9.0",
154155
"jest-sonar-reporter": "^2.0.0",
155-
"lint-staged": "^8.2.1",
156+
"lint-staged": "^9.5.0",
156157
"pre-commit": "^1.2.2",
157-
"react": "^16.8.6",
158-
"react-dom": "^16.8.6",
159-
"react-styleguidist": "^9.1.7",
160-
"rimraf": "^2.6.3",
161-
"rollup": "^1.15.6",
162-
"semantic-release": "^15.13.16",
158+
"react": "^16.12.0",
159+
"react-dom": "^16.12.0",
160+
"react-styleguidist": "^10.2.1",
161+
"rimraf": "^3.0.0",
162+
"semantic-release": "^15.13.31",
163163
"toctoc": "^0.3.2",
164-
"webpack": "^4.34.0"
164+
"webpack": "^4.41.2"
165165
},
166166
"jest": {
167167
"roots": [
@@ -188,10 +188,10 @@
188188
],
189189
"coverageThreshold": {
190190
"global": {
191-
"statements": 99,
192-
"branches": 91,
193-
"functions": 99,
194-
"lines": 99
191+
"statements": 80,
192+
"branches": 80,
193+
"functions": 80,
194+
"lines": 80
195195
}
196196
},
197197
"moduleDirectories": [
@@ -216,8 +216,8 @@
216216
"build:readme"
217217
],
218218
"dependencies": {
219-
"@bootstrap-styled/css-mixins": "^2.0.6",
220-
"@bootstrap-styled/utils": "^1.7.1"
219+
"@bootstrap-styled/css-mixins": "^2.1.1",
220+
"@bootstrap-styled/utils": "^1.8.1"
221221
},
222222
"publishConfig": {
223223
"registry": "https://registry.npmjs.org",

src/_api.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { mediaBreakpointUp, breakpointInfix } from '@bootstrap-styled/css-mixins/lib/breakpoints';
2+
import { generateUtility } from '@bootstrap-styled/css-mixins/lib/utilities';
3+
4+
/**
5+
* @param {object} gridBreakpoints - grid breakpoints
6+
* @param {Map} utilities - map of utilities
7+
* @returns {string} - css screen utilities
8+
*/
9+
export function screenUtilities(
10+
gridBreakpoints,
11+
utilities,
12+
) {
13+
return Object.keys(gridBreakpoints).map((bp) => {
14+
const infix = breakpointInfix(bp, gridBreakpoints);
15+
const utilityList = [];
16+
// eslint-disable-next-line no-unused-vars, no-restricted-syntax
17+
for (const [key, utility] of utilities) {
18+
if (utility && (utility.responsive || infix === '')) {
19+
utilityList.push(generateUtility(utility, infix));
20+
}
21+
}
22+
return mediaBreakpointUp(bp, gridBreakpoints, utilityList.join('\n'));
23+
}).join('\n');
24+
}
25+
26+
export function printUtilities(
27+
gridBreakpoints,
28+
utilities,
29+
) {
30+
const utilityList = [];
31+
// eslint-disable-next-line no-unused-vars, no-restricted-syntax
32+
for (const [key, utility] of utilities) {
33+
if (utility && utility.print === true) {
34+
utilityList.push(generateUtility(utility, '-print'));
35+
}
36+
}
37+
return `@media print {
38+
${utilityList.join('\n')}
39+
}`;
40+
}

0 commit comments

Comments
 (0)