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.
[Color system] Add color factory and build modern tokens (#105)
* Add color factory and build modern color tokens 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> Co-Authored-By: Kaelig Deloumeau-Prigent <kaelig@users.noreply.github.com>
- Loading branch information
1 parent
0806264
commit f80ce5c
Showing
30 changed files
with
1,257 additions
and
148 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.