Skip to content

Commit

Permalink
Fixing es6 format example and adding a js transformGroup (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
dbanksdesign authored Aug 5, 2018
1 parent 83a9d6e commit b7b36f7
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 18 deletions.
33 changes: 18 additions & 15 deletions docs/formats.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Formats are better if there is little to no boilerplate code like a flat SCSS va

Creates a CSS file with variable definitions based on the style dictionary

**Example**
**Example**
```css
:root {
--color-background-base: #f0f0f0;
Expand All @@ -57,7 +57,7 @@ Creates a CSS file with variable definitions based on the style dictionary

Creates a SCSS file with variable definitions based on the style dictionary

**Example**
**Example**
```scss
$color-background-base: #f0f0f0;
$color-background-alt: #eeeeee;
Expand All @@ -70,7 +70,7 @@ $color-background-alt: #eeeeee;

Creates a SCSS file with variable definitions and helper classes for icons

**Example**
**Example**
```scss
$content-icon-email: '\E001';
.icon.email:before { content:$content-icon-email; }
Expand All @@ -83,7 +83,7 @@ $content-icon-email: '\E001';

Creates a LESS file with variable definitions based on the style dictionary

**Example**
**Example**
```less
@color-background-base: #f0f0f0;
@color-background-alt: #eeeeee;
Expand All @@ -96,7 +96,7 @@ Creates a LESS file with variable definitions based on the style dictionary

Creates a LESS file with variable definitions and helper classes for icons

**Example**
**Example**
```less
@content-icon-email: '\E001';
.icon.email:before { content:@content-icon-email; }
Expand All @@ -109,7 +109,7 @@ Creates a LESS file with variable definitions and helper classes for icons

Creates a CommonJS module with the whole style dictionary

**Example**
**Example**
```js
module.exports = {
color: {
Expand All @@ -130,7 +130,7 @@ module.exports = {
Creates a JS file a global var that is a plain javascript object of the style dictionary.
Name the variable by adding a 'name' attribute on the file object in your config.

**Example**
**Example**
```js
var StyleDictionary = {
color: {
Expand All @@ -152,7 +152,7 @@ Creates a [UMD](https://github.com/umdjs/umd) module of the style
dictionary. Name the module by adding a 'name' attribute on the file object
in your config.

**Example**
**Example**
```js
(function(root, factory) {
if (typeof module === "object" && module.exports) {
Expand Down Expand Up @@ -188,12 +188,15 @@ file object in the config.
{
"platforms": {
"js": {
"transformGroup": "js",
"files": [
{
"format": "javascript/es6",
"destination": "colors.js",
"filter": {
"category": "color"
"attributes": {
"category": "color"
}
}
}
]
Expand All @@ -202,10 +205,10 @@ file object in the config.
}
```

**Example**
**Example**
```js
export const BackgroundBase = '#ffffff';
export const BackgroundAlt = '#fcfcfcfc';
export const ColorBackgroundBase = '#ffffff';
export const ColorBackgroundAlt = '#fcfcfcfc';
```

* * *
Expand All @@ -215,7 +218,7 @@ export const BackgroundAlt = '#fcfcfcfc';

Creates a JSON file of the style dictionary.

**Example**
**Example**
```json
{
"color": {
Expand All @@ -235,7 +238,7 @@ Creates a JSON file of the style dictionary.

Creates a JSON file of just the assets defined in the style dictionary.

**Example**
**Example**
```js
{
"asset": {
Expand All @@ -255,7 +258,7 @@ Creates a JSON file of just the assets defined in the style dictionary.

Creates a sketchpalette file of all the base colors

**Example**
**Example**
```json
{
"compatibleVersion": "1.0",
Expand Down
13 changes: 13 additions & 0 deletions docs/transform_groups.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ Transforms:
[color/css](transforms.md#colorcss)


* * *

### js


Transforms:

[attribute/cti](transforms.md#attributecti)
[name/cti/pascal](transforms.md#namectipascal)
[size/rem](transforms.md#sizerem)
[color/hex](transforms.md#colorhex)


* * *

### scss
Expand Down
12 changes: 9 additions & 3 deletions lib/common/formats.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,16 @@ module.exports = {
* {
* "platforms": {
* "js": {
* "transformGroup": "js",
* "files": [
* {
* "format": "javascript/es6",
* "destination": "colors.js"
* "destination": "colors.js",
* "filter": {
* "attributes": {
* "category": "color"
* }
* }
* }
* ]
* }
Expand All @@ -251,8 +257,8 @@ module.exports = {
* @kind member
* @example
* ```js
* export const BackgroundBase = '#ffffff';
* export const BackgroundAlt = '#fcfcfcfc';
* export const ColorBackgroundBase = '#ffffff';
* export const ColorBackgroundAlt = '#fcfcfcfc';
* ```
*/
'javascript/es6': function(dictionary) {
Expand Down
17 changes: 17 additions & 0 deletions lib/common/transformGroups.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ module.exports = {
'color/css'
],

/**
* Transforms:
*
* [attribute/cti](transforms.md#attributecti)
* [name/cti/pascal](transforms.md#namectipascal)
* [size/rem](transforms.md#sizerem)
* [color/hex](transforms.md#colorhex)
*
* @memberof TransformGroups
*/
'js': [
'attribute/cti',
'name/cti/pascal',
'size/rem',
'color/hex'
],

/**
* Transforms:
*
Expand Down

0 comments on commit b7b36f7

Please sign in to comment.