Skip to content
This repository has been archived by the owner on Apr 13, 2022. It is now read-only.

Commit

Permalink
Add color factory and build modern color tokens
Browse files Browse the repository at this point in the history
  * 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
5 people committed Feb 20, 2020
1 parent 0806264 commit ae4bd0a
Show file tree
Hide file tree
Showing 30 changed files with 1,244 additions and 147 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
key: v2-npm-deps-{{ arch }}-{{ checksum "yarn.lock" }}
paths:
- node_modules
- run: yarn run type-check
- run: yarn run build-ci
- run: yarn run test
- run: yarn run lint
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules
/dist
/dist-modern
/tmp
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,5 @@ node_modules

# sewing-kit temporary folder
tmp

dist-modern
2 changes: 1 addition & 1 deletion .npmignore
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
4 changes: 4 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
node_modules
package.json
/.dev
/dist-modern
/tmp
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,18 @@
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
"files.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/node_modules": true,
".{bundle,dev,shadowenv.d}": true,
"{tmp,dist-modern}/": true
},
"search.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/node_modules": true,
"{tmp,dist-modern}/": true
}
}
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

<!-- ## [Unreleased] -->

- Added color factory and built modern tokens ([#105](https://github.com/Shopify/polaris-tokens/pull/105))
- Added surface disabled variant and updated other variant configs ([#101](https://github.com/Shopify/polaris-tokens/pull/101))
- Added TypeScript build for modern tokens, and shifted directory structures to differentiate between legacy and modern tokens ([#97](https://github.com/Shopify/polaris-tokens/pull/97))
- Updated variant names and descriptions ([#96](https://github.com/Shopify/polaris-tokens/pull/96))
- Added decorative icon variants ([#94](https://github.com/Shopify/polaris-tokens/pull/94))
- Built changes from previous release, and added textOnInteractive variant ([#93](https://github.com/Shopify/polaris-tokens/pull/93))
- Fixed an issue where legacy themes caused the color factory to throw ([#92](https://github.com/Shopify/polaris-tokens/pull/92))
- Update color variants for consistency with changes in Polaris React ([#91](https://github.com/Shopify/polaris-tokens/pull/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](https://github.com/Shopify/polaris-tokens/commit/49988564d7048c73e53cd85eab89f5ff49d0e28b))
- Added the Color Factory. Long live the Color Factory! ([#89](https://github.com/Shopify/polaris-tokens/pull/89))

## [2.7.0] - 2019-10-28

- Updated filter for the Blue color ([#64](https://github.com/Shopify/polaris-tokens/pull/64))
Expand Down
5 changes: 2 additions & 3 deletions docs/index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion docs/index.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions formats/tokens.js
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};
Loading

0 comments on commit ae4bd0a

Please sign in to comment.