mirror of
https://github.com/primer/css.git
synced 2024-09-19 04:37:38 +03:00
Properly calculating the variables computed value for dist
This commit is contained in:
parent
e02694d1ba
commit
93b40e7b7d
@ -49,6 +49,7 @@
|
|||||||
"jest": "26.6.3",
|
"jest": "26.6.3",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"postcss": "8.3.0",
|
"postcss": "8.3.0",
|
||||||
|
"postcss-calc": "8.0.0",
|
||||||
"postcss-import": "14.0.2",
|
"postcss-import": "14.0.2",
|
||||||
"postcss-load-config": "3.0.1",
|
"postcss-load-config": "3.0.1",
|
||||||
"postcss-node-sass": "3.1.0",
|
"postcss-node-sass": "3.1.0",
|
||||||
|
@ -4,6 +4,7 @@ const {join} = require('path')
|
|||||||
const fs = require('fs')
|
const fs = require('fs')
|
||||||
const atImport = require('postcss-import')
|
const atImport = require('postcss-import')
|
||||||
const syntax = require('postcss-scss')
|
const syntax = require('postcss-scss')
|
||||||
|
const calc = require('postcss-calc')
|
||||||
|
|
||||||
const processor = postcss([
|
const processor = postcss([
|
||||||
atImport({path: ['src']}),
|
atImport({path: ['src']}),
|
||||||
@ -20,7 +21,14 @@ async function analyzeVariables(fileName) {
|
|||||||
if (!result.variables[`$${message.name}`].values.includes(message.value)) {
|
if (!result.variables[`$${message.name}`].values.includes(message.value)) {
|
||||||
result.variables[`$${message.name}`].values.push(message.value)
|
result.variables[`$${message.name}`].values.push(message.value)
|
||||||
}
|
}
|
||||||
const computed = message.value
|
let computed = message.value
|
||||||
|
try {
|
||||||
|
const c = `--temp-property: calc(${message.value})`.replace('round(', '(')
|
||||||
|
computed = postcss().use(calc()).process(c).css
|
||||||
|
computed = computed.replace('--temp-property: ', '')
|
||||||
|
} catch (e) {
|
||||||
|
// Couldn't calculate because value might not be a number
|
||||||
|
}
|
||||||
result.variables[`$${message.name}`].computed = computed
|
result.variables[`$${message.name}`].computed = computed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5337,6 +5337,14 @@ posix-character-classes@^0.1.0:
|
|||||||
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab"
|
||||||
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
|
integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=
|
||||||
|
|
||||||
|
postcss-calc@8.0.0:
|
||||||
|
version "8.0.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/postcss-calc/-/postcss-calc-8.0.0.tgz#a05b87aacd132740a5db09462a3612453e5df90a"
|
||||||
|
integrity sha512-5NglwDrcbiy8XXfPM11F3HeC6hoT9W7GUH/Zi5U/p7u3Irv4rHhdDcIZwG0llHXV4ftsBjpfWMXAnXNl4lnt8g==
|
||||||
|
dependencies:
|
||||||
|
postcss-selector-parser "^6.0.2"
|
||||||
|
postcss-value-parser "^4.0.2"
|
||||||
|
|
||||||
postcss-custom-properties@^10.0.0:
|
postcss-custom-properties@^10.0.0:
|
||||||
version "10.0.0"
|
version "10.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-10.0.0.tgz#5cb31afc530f58ad241f1e836dd5f5f7065334df"
|
resolved "https://registry.yarnpkg.com/postcss-custom-properties/-/postcss-custom-properties-10.0.0.tgz#5cb31afc530f58ad241f1e836dd5f5f7065334df"
|
||||||
|
Loading…
Reference in New Issue
Block a user