This repository has been archived by the owner on Apr 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add color factory and build modern color tokens
* Added surface disabled variant and updated other variant configs ([#101](#101)) * Added TypeScript build for modern tokens, and shifted directory structures to differentiate between legacy and modern tokens ([#97](#97)) * Updated variant names and descriptions ([#96](#96)) * Added decorative icon variants ([#94](#94)) * Built changes from previous release, and added textOnInteractive variant ([#93](#93)) * Fixed an issue where legacy themes caused the color factory to throw ([#92](#92)) * Update color variants for consistency with changes in Polaris React ([#91](#91)) * Marked the config as optional and the colors as partial ([dd3d8fc](https://github.com/Shopify/polaris-tokens/commit/ * Actually exporting the types would be helpful ([4998856](4998856)) * Added the Color Factory. Long live the Color Factory! ([#89](#89)) Co-authored-by: Dan Rosenthal <dan.rosenthal@shopify.com> Co-authored-by: Ben Scott <227292+BPScott@users.noreply.github.com> Co-authored-by: Kyle Durand <kyle.durand@shopify.com> Co-authored-by: Sara Hill <sara.hill@shopify.com>
- Loading branch information
1 parent
0806264
commit ae4bd0a
Showing
30 changed files
with
1,244 additions
and
147 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
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,4 @@ | ||
node_modules | ||
/dist | ||
/dist-modern | ||
/tmp |
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 |
---|---|---|
|
@@ -15,3 +15,5 @@ node_modules | |
|
||
# sewing-kit temporary folder | ||
tmp | ||
|
||
dist-modern |
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 |
---|---|---|
@@ -1,8 +1,8 @@ | ||
**/* | ||
!dist/**/* | ||
!dist-modern/**/* | ||
!index.js | ||
!LICENSE.md | ||
!README.md | ||
!package.json | ||
!yarn.lock | ||
dist/colors.ase.json |
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 |
---|---|---|
@@ -1 +1,5 @@ | ||
node_modules | ||
package.json | ||
/.dev | ||
/dist-modern | ||
/tmp |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
|
||
const {colorFactory} = require('../dist-modern/color-factory.js'); | ||
const {tokensToJson} = require('../dist-modern/utils'); | ||
|
||
function tokenify(scheme) { | ||
return (result) => { | ||
const configFile = path.basename(result.toJS().meta.file, '.yml'); | ||
const config = `${__dirname}/../dist-modern/configs/${configFile}`; | ||
let configArg; | ||
|
||
if (fs.existsSync(`${config}.js`)) { | ||
configArg = require(`../dist-modern/configs/${configFile}`).config; | ||
} | ||
|
||
const theme = tokensToJson(result); | ||
const palette = colorFactory(theme, scheme, configArg); | ||
|
||
const yml = Object.entries(palette).reduce((accumulator, [key, value]) => { | ||
return `${accumulator} - name: ${key}\n value: '${value}'\n`; | ||
}, ''); | ||
|
||
return `props:\n${yml}global:\n type: color\n category: background-color\n`; | ||
}; | ||
} | ||
|
||
module.exports = {tokenify}; |
Oops, something went wrong.