Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(extend): use given file path for token data #499

Merged
merged 5 commits into from
Dec 19, 2020
Merged

fix(extend): use given file path for token data #499

merged 5 commits into from
Dec 19, 2020

Conversation

dbanksdesign
Copy link
Member

@dbanksdesign dbanksdesign commented Dec 8, 2020

Issue #, if available: #498

Description of changes: Changed the filePath attribute Style Dictionary adds to all tokens to be the filePath provided by 'source' or 'includes'. If you provide a relative file path like ["tokens/**/*.json"] then filePath will now be "tokens/color/core.json" rather than "/Users/djb/dev/my-style-dictionary/tokens/color/core.json" for example.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@luke-john
Copy link
Contributor

Tested this on our codebase and works nicely.

Just a note that the documentation at https://github.com/amzn/style-dictionary/blob/main/docs/version_3.md#adding-filepath-and-issource-entries-on-tokens will likely need updating to something like follows.

- filePath: A string representing the absolute path of the file that defines the token. This will help with debugging and if you want to output files based on the source files.
+ filePath: A string representing the path of the file that defines the token, will be relative or absolute based on the source or includes entry which picked up the file. This will help with debugging and if you want to output files based on the source files. 

Copy link
Contributor

@didoo didoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code is OK for me

@@ -28,7 +28,7 @@ There are 3 types of transforms: attribute, name, and value.
**Value:** The value transform is the most important as this is the one that changes the representation of the value. Colors can be turned into hex values, rgb, hsl, hsv, etc. Value transforms have a matcher function that filter which properties that transform runs on. This allows us to only run a color transform on only the colors and not every property.

## Defining Custom Transforms
You can define custom transforms with the [`registerTransform`](api.md#registertransform).
You can define custom transforms with the [`registerTransform`](api.md#registertransform). Style Dictionary adds some [default metadata](properties.md?id=default-property-metadata) to each property/token to help with transforms.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to help with transforms

to provide context that may be useful for some transforms.

@@ -32,7 +32,7 @@ There are 3 types of transforms: attribute, name, and value.
**Value:** The value transform is the most important as this is the one that changes the representation of the value. Colors can be turned into hex values, rgb, hsl, hsv, etc. Value transforms have a matcher function that filter which properties that transform runs on. This allows us to only run a color transform on only the colors and not every property.

## Defining Custom Transforms
You can define custom transforms with the [`registerTransform`](api.md#registertransform).
You can define custom transforms with the [`registerTransform`](api.md#registertransform). Style Dictionary adds some [default metadata](properties.md?id=default-property-metadata) to each property/token to help with transforms.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to help with transforms

to provide context that may be useful for some transforms.

@@ -71,6 +71,8 @@ A special file configuration is `filter`, which will filter the tokens before th
}
```

The token/property that is passed to the filter function has already been [transformed](transforms.md) and has [default metadata](properties.md?id=default-property-metadata) added by Style Dictionary.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure default is the right adjective. as opposed to optional metadata? might be worth considering the wording here.

@chazzmoney
Copy link
Collaborator

LGTM :shipit:

@chazzmoney chazzmoney merged commit 0b23c9d into 3.0 Dec 19, 2020
dbanksdesign added a commit that referenced this pull request Jan 25, 2021
* fix(extend): use given file path for token data
* docs(properties): update properties doc to reflect new additions
* docs(property): adding default metadata to property docs
* docs(properties): adding more context to default metadata
* docs(properties): cleaning up default metadata docs
@dbanksdesign dbanksdesign deleted the fix-498 branch March 12, 2021 22:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants