Skip to content

Commit

Permalink
chore(types): adds filePath and isSource to Prop and descriptions to …
Browse files Browse the repository at this point in the history
…Props keys (#501)

These descriptions are based on the `Default property metadata`
section in the `Properties` docs.
  • Loading branch information
luke-john authored Jan 12, 2021
1 parent 32787f8 commit 99b3357
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Style Dictionary adds some metadata on each property that helps with transforms
| Attribute | Type | Description |
| :--- | :--- | :--- |
| name | String | A default name of the property that is set to the key of the property.
| path | Array[String] | The object path of the property. `color: { background: primary: {value: "#fff"}}` will have a path of `['color','background', 'primary']`.
| path | Array[String] | The object path of the property. `color: { background: { primary: { value: "#fff" } } }` will have a path of `['color','background', 'primary']`.
| original | Object | A pristine copy of the original property object. This is to make sure transforms and formats always have the unmodified version of the original property.
| filePath | String | The file path of the file the token is defined in. This file path is derived from the `source` or `include` file path arrays defined in the [configuration](config.md).
| isSource | Boolean | If the token is from a file defined in the `source` array as opposed to `include` in the [configuration](config.md).
Expand Down
26 changes: 23 additions & 3 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,31 @@ declare namespace StyleDictionary {
}

interface Prop {
original: Property;
/** A default name of the property that is set to the key of the property. */
name: string;
attributes: Attributes;
path: string[];
value: string;
/** The object path of the property.
*
* `color: { background: { primary: { value: "#fff" } } }` will have a path of `['color', 'background', 'primary']`.
*/
path: string[];
/**
* A pristine copy of the original property object.
*
* This is to make sure transforms and formats always have the unmodified version of the original property.
*/
original: Property;
/**
* The file path of the file the token is defined in.
*
* This file path is derived from the source or include file path arrays defined in the configuration.
*/
filePath: string;
/**
* If the token is from a file defined in the source array as opposed to include in the [configuration](https://amzn.github.io/style-dictionary/#/config).
*/
isSource: boolean;
attributes: Attributes;
[key: string]: any;
}

Expand Down

0 comments on commit 99b3357

Please sign in to comment.