From e78a9d2d28c2461ec7fc54cdcf6d4cab37567e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Mon, 27 Feb 2017 17:38:43 +0000 Subject: [PATCH] support remcalc('i i') --- ui/package.json | 1 + ui/src/shared/functions.js | 13 +++++++++---- ui/yarn.lock | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/package.json b/ui/package.json index 6c286176..03000383 100644 --- a/ui/package.json +++ b/ui/package.json @@ -75,6 +75,7 @@ "eslint-plugin-react": "^6.10.0", "eslint-plugin-standard": "^2.0.1", "jsdom": "^9.11.0", + "lodash.flatten": "^4.4.0", "memory-fs": "^0.4.1", "node-hook": "^0.4.0", "nyc": "^10.1.2", diff --git a/ui/src/shared/functions.js b/ui/src/shared/functions.js index 1f23db4f..83086664 100644 --- a/ui/src/shared/functions.js +++ b/ui/src/shared/functions.js @@ -1,6 +1,7 @@ import { css } from 'styled-components'; import calc from 'reduce-css-calc'; import randomNatural from 'random-natural'; +import flatten from 'lodash.flatten'; const remBase = 16; const unitBase = 6; @@ -18,12 +19,16 @@ const rndId = (_code) => { : lastDigit; }; -const remcalc = (...values) => values.map((value) => ( - `${String(value).replace('px', '') / remBase}rem` +const remcalc = (...values) => flatten( + values.map((value) => String(value).split(/\s/img)) +).map((value) => ( + `${value.replace('px', '') / remBase}rem` )).join(' '); -const unitcalc = (...values) => values.map( - (value) => remcalc(value * unitBase) +const unitcalc = (...values) => flatten( + values.map((value) => String(value).split(/\s/img)) +).map((value) => + remcalc(Number(value) * unitBase) ); const cssCalc = (str) => calc(`calc(${str})`); diff --git a/ui/yarn.lock b/ui/yarn.lock index cf626e62..01e70ef8 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -4252,7 +4252,7 @@ lodash.first@^3.0.0: version "3.0.0" 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" resolved "https://registry.yarnpkg.com/lodash.flatten/-/lodash.flatten-4.4.0.tgz#f31c22225a9632d2bbf8e4addbef240aa765a61f"