flow like the river
This commit is contained in:
commit
013fe673f3
42435 changed files with 5764238 additions and 0 deletions
36
VISUALIZACION/node_modules/polished/lib/helpers/getValueAndUnit.js
generated
vendored
Executable file
36
VISUALIZACION/node_modules/polished/lib/helpers/getValueAndUnit.js
generated
vendored
Executable file
|
|
@ -0,0 +1,36 @@
|
|||
"use strict";
|
||||
|
||||
exports.__esModule = true;
|
||||
exports["default"] = getValueAndUnit;
|
||||
var cssRegex = /^([+-]?(?:\d+|\d*\.\d+))([a-z]*|%)$/;
|
||||
|
||||
/**
|
||||
* Returns a given CSS value and its unit as elements of an array.
|
||||
*
|
||||
* @example
|
||||
* // Styles as object usage
|
||||
* const styles = {
|
||||
* '--dimension': getValueAndUnit('100px')[0],
|
||||
* '--unit': getValueAndUnit('100px')[1],
|
||||
* }
|
||||
*
|
||||
* // styled-components usage
|
||||
* const div = styled.div`
|
||||
* --dimension: ${getValueAndUnit('100px')[0]};
|
||||
* --unit: ${getValueAndUnit('100px')[1]};
|
||||
* `
|
||||
*
|
||||
* // CSS in JS Output
|
||||
*
|
||||
* element {
|
||||
* '--dimension': 100,
|
||||
* '--unit': 'px',
|
||||
* }
|
||||
*/
|
||||
function getValueAndUnit(value) {
|
||||
if (typeof value !== 'string') return [value, ''];
|
||||
var matchedValue = value.match(cssRegex);
|
||||
if (matchedValue) return [parseFloat(value), matchedValue[2]];
|
||||
return [value, undefined];
|
||||
}
|
||||
module.exports = exports.default;
|
||||
Loading…
Add table
Add a link
Reference in a new issue