-
Notifications
You must be signed in to change notification settings - Fork 567
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
Conversation
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. |
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
docs/transforms.md
Outdated
@@ -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. |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
LGTM |
* 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
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.