1
0
mirror of https://github.com/yldio/copilot.git synced 2024-11-28 14:10:04 +02:00

support remcalc('i i')

This commit is contained in:
Sérgio Ramos 2017-02-27 17:38:43 +00:00
parent 961a06f46a
commit e78a9d2d28
3 changed files with 11 additions and 5 deletions

View File

@ -75,6 +75,7 @@
"eslint-plugin-react": "^6.10.0", "eslint-plugin-react": "^6.10.0",
"eslint-plugin-standard": "^2.0.1", "eslint-plugin-standard": "^2.0.1",
"jsdom": "^9.11.0", "jsdom": "^9.11.0",
"lodash.flatten": "^4.4.0",
"memory-fs": "^0.4.1", "memory-fs": "^0.4.1",
"node-hook": "^0.4.0", "node-hook": "^0.4.0",
"nyc": "^10.1.2", "nyc": "^10.1.2",

View File

@ -1,6 +1,7 @@
import { css } from 'styled-components'; import { css } from 'styled-components';
import calc from 'reduce-css-calc'; import calc from 'reduce-css-calc';
import randomNatural from 'random-natural'; import randomNatural from 'random-natural';
import flatten from 'lodash.flatten';
const remBase = 16; const remBase = 16;
const unitBase = 6; const unitBase = 6;
@ -18,12 +19,16 @@ const rndId = (_code) => {
: lastDigit; : lastDigit;
}; };
const remcalc = (...values) => values.map((value) => ( const remcalc = (...values) => flatten(
`${String(value).replace('px', '') / remBase}rem` values.map((value) => String(value).split(/\s/img))
).map((value) => (
`${value.replace('px', '') / remBase}rem`
)).join(' '); )).join(' ');
const unitcalc = (...values) => values.map( const unitcalc = (...values) => flatten(
(value) => remcalc(value * unitBase) values.map((value) => String(value).split(/\s/img))
).map((value) =>
remcalc(Number(value) * unitBase)
); );
const cssCalc = (str) => calc(`calc(${str})`); const cssCalc = (str) => calc(`calc(${str})`);

View File

@ -4252,7 +4252,7 @@ lodash.first@^3.0.0:
version "3.0.0" version "3.0.0"
resolved "https://registry.yarnpkg.com/lodash.first/-/lodash.first-3.0.0.tgz#5dae180d7f818ee65fc5b210b104a7bbef98a16a" resolved "https://registry.yarnpkg.com/lodash.first/-/lodash.first-3.0.0.tgz#5dae180d7f818ee65fc5b210b104a7bbef98a16a"
lodash.flatten@^4.2.0, lodash.flatten@^4.4.0: lodash.flatten, lodash.flatten@^4.2.0, lodash.flatten@^4.4.0:
version "4.4.0" version "4.4.0"
resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"