question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add header to all formats

See original GitHub issue

Hey @dbanksdesign, I am trying to get the style-dictionary to work with the design token spec idea outlined by the w3c community group: https://github.com/design-tokens/community-group/issues/1

Getting the tokens out works fine in a custom build file like this

const StyleDictionaryExtended = require('style-dictionary').extend(__dirname + '/config.json');
const {tokens, version, data} = require(__dirname + '/tokens/w3c-design-tokens.json')
console.log('Build started...');
console.log('\n==============================================');
// turning array into a style-dictionary compatible object
StyleDictionaryExtended.properties = tokens.reduce((acc, item) => ({
  ...acc, [item.name]: item
}), {})

However, I would love to add the version and maybe some meta data from the data constants to the header of every transformed output. It seems to be quite cumbersome to create a custom format with StyleDictionaryExtended.registerFormat for every language (sass, json, ios, android) just to add a header.

So I was wondering, is there a way to add some content to the header for all files?

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:15 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
chazzmoneycommented, Mar 13, 2021

@dbanksdesign can’t we just do it the way we do everything else? Allow registration of formatHelpers / via extend?

2reactions
lukasoppermanncommented, Mar 12, 2021

Hey @dbanksdesign that sounds great. I wasn’t sure how long it will take until the release (as I know form my own project that OS is always quite a lot of work).

I would think allowing users to extend the fileHeader function could be a great way. Maybe by adding an array of lines (or a function that returns an array of lines) and those lines will be added to the header?

E.g. in the build.js file

// usage
StyleDictionary.formatHelpers.fileHeader.extend([
`Version: ${version}`,
`Some other org specific info`
])

// Would result in (style = short)

// Do not edit directly\n';
// Generated on dd.mm.yyyy
// Version: 2.3.12
// Some other org specific info

I don’t know if this is a stupid idea as I just quickly dove into the code. But it would be great if one could overwrite or extend the fileHeader once in build.js and it would be used for all formats (without a need to overwrite all the formats).

Does this make sense?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Insert a header or footer - Microsoft Support
Go to Insert > Header or Footer. Choose the header style you want to use. Tip: Some built-in header and footer designs include...
Read more >
Office Q&A: Adding custom headers to Word's Headers gallery
In this article, we'll add a custom header to the Headers gallery by saving the custom content as a building block.
Read more >
How to Insert Custom Headers and Footers in Microsoft Word
Use the Built-In Headers and Footers in Word · Go to the Header & Footer section of the Insert tab on the ribbon...
Read more >
Excel header and footer: how to add, change and remove
To insert headers or footers on multiple worksheets at a time, select all target sheets, and then add a header or footer in...
Read more >
Insert a header or footer in Microsoft Word - YouTube
Use headers and footers to add a title, date, or page numbers to every page in a document. Learn more at the Office...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found