-
Notifications
You must be signed in to change notification settings - Fork 507
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add precompile step for colorSchemes (#4337)
* Add precompile step for colorSchemes * ignore generated file in prettier * Create tasty-spoons-suffer.md
- Loading branch information
1 parent
2c0086e
commit 69f4489
Showing
7 changed files
with
4,776 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
Add precompile step for colorSchemes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ storybook-static | |
docs/.cache | ||
docs/public | ||
**/.next/** | ||
packages/react/src/legacy-theme/ts/color-schemes.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
import {colors} from '../src/legacy-theme/ts/colors' | ||
import {partitionColors, omitScale} from '../src/utils/theme' | ||
|
||
const colorSchemes = Object.entries(colors).reduce((acc, [name, variables]) => { | ||
const {colors, shadows} = partitionColors(variables) | ||
return { | ||
...acc, | ||
[name]: { | ||
colors: omitScale(colors), | ||
shadows: omitScale(shadows), | ||
}, | ||
} | ||
}, {}) | ||
|
||
const colorSchemeFileContent = `// This file is auto-generated by precompile-color-schemes.ts | ||
// run \`npm run build:precompile-color-schemes\` to regenerate | ||
type Scheme = keyof typeof colors | ||
type SchemeValue = Record<'colors' | 'shadows', Partial<typeof colors.light>> | ||
const colors = ${JSON.stringify(colorSchemes, null, 2)} | ||
export const colorSchemes: Record<Scheme, SchemeValue> = colors as Record<Scheme, SchemeValue> | ||
` | ||
|
||
fs.writeFileSync(path.join(__dirname, '../src/legacy-theme/ts/color-schemes.ts'), colorSchemeFileContent) |
4,736 changes: 4,736 additions & 0 deletions
4,736
packages/react/src/legacy-theme/ts/color-schemes.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters