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

feat(formats): adding custom file headers #572

Merged
merged 2 commits into from
Mar 19, 2021
Merged

feat(formats): adding custom file headers #572

merged 2 commits into from
Mar 19, 2021

Conversation

dbanksdesign
Copy link
Member

@dbanksdesign dbanksdesign commented Mar 18, 2021

Issue #, if available: #566

Description of changes: Adding custom file headers to output files. You can add custom file headers with a register method, .registerFileHeader or directly on the Style Dictionary configuration, similar to custom formats. Custom file headers can be used in custom formats as well with the StyleDictionary.formatHelpers.fileHeader() method.

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

@dbanksdesign dbanksdesign mentioned this pull request Mar 18, 2021

const myCustomFormat = ({ dictionary, file }) => {
return `${fileHeader(file, 'short')}${dictionary.allProperties.map(token => {
return `$${token.name}: ${token.value};`
Copy link
Collaborator

Choose a reason for hiding this comment

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

$$

@chazzmoney
Copy link
Collaborator

minus the single comment, which I believe is a typo, LGTM!

docs/api.md Outdated
| --- | --- | --- |
| options | <code>Object</code> | |
| options.name | <code>String</code> | Name of the format to be referenced in your config.json |
| options.fileHeader | <code>function</code> | Function that returns an array of strings, which will be mapped to comment lines. Takes a single which is the default message array. See [file headers](formats.md#file-headers) for more information. |
Copy link
Contributor

Choose a reason for hiding this comment

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

Takes a single which is

Missing a word in the middle?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch.

Takes a single which is the default message array

@chazzmoney
Copy link
Collaborator

LGTM! :shipit:

@dbanksdesign dbanksdesign merged commit 2a29502 into 3.0 Mar 19, 2021
@dbanksdesign dbanksdesign deleted the fix-566 branch March 19, 2021 23:21
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.

3 participants