Skip to content

Commit

Permalink
Update fallback plugin to inline hex colors from light
Browse files Browse the repository at this point in the history
  • Loading branch information
jonrohan committed Jul 10, 2024
1 parent fa29d99 commit 42ebf4d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
26 changes: 21 additions & 5 deletions packages/react/rollup.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -134,19 +134,35 @@ const baseConfig = {
importFrom: [
() => {
let customProperties = {}
const filePaths = glob.sync(['**/*.json'], {
cwd: path.join(__dirname, '../../node_modules/@primer/primitives/dist/fallbacks/'),
ignore: ['color-fallbacks.json'],
const filePaths = glob.sync(['fallbacks/**/*.json', 'docs/functional/themes/light.json'], {
cwd: path.join(__dirname, '../../node_modules/@primer/primitives/dist/'),
ignore: ['fallbacks/color-fallbacks.json'],
})

for (const filePath of filePaths) {
const fileData = fs.readFileSync(
path.join(__dirname, '../../node_modules/@primer/primitives/dist/fallbacks/', filePath),
path.join(__dirname, '../../node_modules/@primer/primitives/dist/', filePath),
'utf8',
)

if (fileData.includes('--color-border-default')) {
console.log(filePath)
}

const jsonData = JSON.parse(fileData)
let result = {}

if (filePath === 'docs/functional/themes/light.json') {
for (const variable of Object.keys(jsonData)) {
result[`--${variable}`] = jsonData[variable].value
}
} else {
result = jsonData
}

customProperties = {
...customProperties,
...JSON.parse(fileData),
...result,
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Button/ButtonBase.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
.ButtonBase {
border-radius: var(--borderRadius-medium);
border: var(--borderWidth-thin) solid;
border-color: var(--button-default-borderColor-rest, var(--borderColor-default));
border-color: var(--button-default-borderColor-rest);
font-family: inherit;
font-weight: var(--base-text-weight-medium);
font-size: var(--text-body-size-medium);
Expand Down

0 comments on commit 42ebf4d

Please sign in to comment.