Skip to content

Commit 352ed7b

Browse files
authored
Add new PostCSS fallback config (#2457)
* add new fallback config * Create swift-moles-jump.md
1 parent 344224f commit 352ed7b

File tree

4 files changed

+35
-9
lines changed

4 files changed

+35
-9
lines changed

.changeset/swift-moles-jump.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@primer/css": patch
3+
---
4+
5+
Add new PostCSS fallback config

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"storybook": "cd docs && yarn && yarn storybook"
4343
},
4444
"dependencies": {
45-
"@primer/primitives": "^7.11.10",
45+
"@primer/primitives": "^7.11.12",
4646
"@primer/view-components": "^0.1.0"
4747
},
4848
"devDependencies": {

postcss.config.cjs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ const sass = require('@csstools/postcss-sass')
33
const scss = require('postcss-scss')
44
const scssImport = require('postcss-import')
55
const { join } = require('path')
6-
const importedJSONFromPrimitives = require('./node_modules/@primer/primitives/tokens-next-private/fallbacks/color-fallbacks.json')
6+
const path = require('path')
7+
const fs = require('fs')
78

89
module.exports = {
910
map: {
@@ -20,9 +21,29 @@ module.exports = {
2021
}),
2122
autoprefixer,
2223
require('postcss-custom-properties-fallback')({
23-
importFrom: {
24-
customProperties: importedJSONFromPrimitives
25-
},
24+
importFrom: [
25+
() => {
26+
const primitiveFallbacks = [
27+
'color-fallbacks.json',
28+
'base/size/size.json',
29+
'base/typography/typography.json',
30+
'functional/size/border.json',
31+
'functional/size/breakpoints.json',
32+
'functional/size/size-coarse.json',
33+
'functional/size/size-fine.json',
34+
'functional/size/size.json',
35+
'functional/size/viewport.json',
36+
'functional/typography/typography.json',
37+
]
38+
let customProperties = {}
39+
for (const filePath of primitiveFallbacks) {
40+
const fileData = fs.readFileSync(path.join(__dirname, './node_modules/@primer/primitives/tokens-next-private/fallbacks/', filePath), 'utf8')
41+
customProperties = {...customProperties, ...JSON.parse(fileData)}
42+
}
43+
44+
return { customProperties: customProperties };
45+
}
46+
]
2647
}),
2748
]
2849
}

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -960,10 +960,10 @@
960960
resolved "https://registry.yarnpkg.com/@primer/behaviors/-/behaviors-1.3.4.tgz#04498185ad4504d85081d4288c74dc3f0e507c8b"
961961
integrity sha512-j6PhkDD1IdL9xrlKbUQ3YEM74B7Fgr1mIZJ6JaYJjM1Mvdutd/nBouM8SnwFZdBBbS+ZRfGhnx3plr833Pvf1Q==
962962

963-
"@primer/primitives@^7.11.10":
964-
version "7.11.10"
965-
resolved "https://registry.yarnpkg.com/@primer/primitives/-/primitives-7.11.10.tgz#9572358f1209dcd2ce3f1f0de12188dffae038e5"
966-
integrity sha512-KwChxyp4qbLojZx5Nz8RUElM9K+ObzZWvzkYEu76TC4qEsqb9wW7n78jyov5WhUh5+qj2Qac1iCsPfeTQG5YBw==
963+
"@primer/primitives@^7.11.12":
964+
version "7.11.12"
965+
resolved "https://registry.yarnpkg.com/@primer/primitives/-/primitives-7.11.12.tgz#1a36354e789f8cc3c178b66b2d100b64d4fb209d"
966+
integrity sha512-AvTiuLHvvby2KPZbwwJ7GrtRJYgWyepF6XAOMw7G7Kc2iP3E32OHmaFukwh3gY+OqwcxY7st2tHWll2brk1vfQ==
967967

968968
"@primer/stylelint-config@^12.4.0":
969969
version "12.7.0"

0 commit comments

Comments
 (0)