@cryptic-css/prop-mq
Advanced tools
Comparing version 3.4.0 to 3.5.0
@@ -6,10 +6,13 @@ # Change Log | ||
# [3.4.0](https://github.com/wintercounter/ccss/compare/v3.3.0...v3.4.0) (2020-05-11) | ||
# [3.5.0](https://github.com/wintercounter/ccss/compare/v3.3.0...v3.5.0) (2020-06-06) | ||
**Note:** Version bump only for package @cryptic-css/prop-mq | ||
### Features | ||
* **props:** add support for booleans ([a32fded](https://github.com/wintercounter/ccss/commit/a32fded31d2847b3a5edd94ed9e409e111c838e8)) | ||
# [3.3.0](https://github.com/wintercounter/ccss/compare/v3.2.1...v3.3.0) (2020-04-17) | ||
@@ -16,0 +19,0 @@ |
import { mediaQuery } from '@w11r/use-breakpoint'; | ||
const handleMqElem = (value, state, t, api) => { | ||
const extracted = api.extractStaticValues(value.elements[1], state, t); | ||
if (Object.keys(extracted).length) { | ||
return [value.elements[0].value, extracted]; | ||
} | ||
}; | ||
const babelPluginHandler = (attr, state, t, api) => { | ||
let extracted; | ||
let isStatic; | ||
if (attr.realValue.elements[0] && !t.isArrayExpression(attr.realValue.elements[0])) { | ||
extracted = handleMqElem(attr.realValue, state, t, api); | ||
isStatic = !attr.realValue.elements[1].properties.length; | ||
} else { | ||
extracted = []; | ||
attr.realValue.elements.filter(el => { | ||
const ext = handleMqElem(el, state, t, api); | ||
ext && extracted.push(ext); | ||
return el.elements[1].properties.length; | ||
}); | ||
isStatic = !attr.realValue.elements.length; | ||
} | ||
return { | ||
pureValue: extracted, | ||
ccssValue: { | ||
[attr.name.name]: extracted | ||
}, | ||
isStatic, | ||
isExtracted: !!extracted | ||
}; | ||
}; | ||
export default ((_ref) => { | ||
@@ -7,3 +43,3 @@ let { | ||
props.mq = (input, prop, options) => { | ||
const handler = (input, prop, options) => { | ||
if (typeof input[0] === 'string') { | ||
@@ -22,2 +58,5 @@ input = [input]; | ||
}; | ||
props.mq = handler; | ||
handler.babelPluginHandler = babelPluginHandler; | ||
}); |
{ | ||
"name": "@cryptic-css/prop-mq", | ||
"version": "3.4.0", | ||
"version": "3.5.0", | ||
"description": "Adds support for the `mq` prop to write media queries using `@w11r/use-breakpoint`.", | ||
@@ -8,3 +8,4 @@ "author": "Victor Vincent <wintercounter+ccss@gmail.com>", | ||
"license": "MIT", | ||
"main": "dist/index.js", | ||
"main": "dist/cjs/index.js", | ||
"module": "dist/index.js", | ||
"publishConfig": { | ||
@@ -20,5 +21,49 @@ "access": "public" | ||
"test:watch": "mhy jest --watchAll", | ||
"build": "mhy bb --mhy-env=prod", | ||
"build": "npm run build:es6 && npm run build:cjs", | ||
"build:es6": "mhy bb --mhy-env=prod", | ||
"build:cjs": "mhy bb --mhy-env=prod:cjs", | ||
"config": "mhy config typescript -io" | ||
}, | ||
"mhy": { | ||
"mhy": { | ||
"cjs": { | ||
"distFolder": "dist/cjs" | ||
} | ||
}, | ||
"babel": { | ||
"cjs": { | ||
"presets": [ | ||
{ | ||
"$match": { | ||
"query": "$[?(@[0].includes('preset-env'))]", | ||
"value": [ | ||
{ | ||
"$match": { | ||
"index": 1, | ||
"value": { | ||
"modules": "commonjs", | ||
"targets": { | ||
"$replace": { | ||
"node": true, | ||
"browsers": false, | ||
"esmodules": true | ||
} | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
} | ||
], | ||
"plugins": [ | ||
{ | ||
"$prepend": { | ||
"$expression": "$params.require.resolve('babel-plugin-add-module-exports')" | ||
} | ||
} | ||
] | ||
} | ||
} | ||
}, | ||
"bugs": { | ||
@@ -34,5 +79,5 @@ "url": "https://github.com/wintercounter/ccss/issues" | ||
"devDependencies": { | ||
"@cryptic-css/core": "^3.4.0" | ||
"@cryptic-css/core": "^3.5.0" | ||
}, | ||
"gitHead": "046c392acedba4e324349ebfa140f3c10721a226" | ||
} |
import { mediaQuery } from '@w11r/use-breakpoint' | ||
const handleMqElem = (value, state, t, api) => { | ||
const extracted = api.extractStaticValues(value.elements[1], state, t) | ||
if (Object.keys(extracted).length) { | ||
return [value.elements[0].value, extracted] | ||
} | ||
} | ||
const babelPluginHandler = (attr, state, t, api) => { | ||
let extracted | ||
let isStatic | ||
if (attr.realValue.elements[0] && !t.isArrayExpression(attr.realValue.elements[0])) { | ||
extracted = handleMqElem(attr.realValue, state, t, api) | ||
isStatic = !attr.realValue.elements[1].properties.length | ||
} else { | ||
extracted = [] | ||
attr.realValue.elements.filter(el => { | ||
const ext = handleMqElem(el, state, t, api) | ||
ext && extracted.push(ext) | ||
return el.elements[1].properties.length | ||
}) | ||
isStatic = !attr.realValue.elements.length | ||
} | ||
return { | ||
pureValue: extracted, | ||
ccssValue: { [attr.name.name]: extracted }, | ||
isStatic, | ||
isExtracted: !!extracted | ||
} | ||
} | ||
export default ({ props }) => { | ||
props.mq = (input, prop, options) => { | ||
const handler = (input, prop, options) => { | ||
if (typeof input[0] === 'string') { | ||
@@ -16,2 +46,4 @@ input = [input] | ||
} | ||
props.mq = handler | ||
handler.babelPluginHandler = babelPluginHandler | ||
} |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
16818
10
316
1