Skip to content

Commit

Permalink
fix: added custom title for CSS output files (#1985)
Browse files Browse the repository at this point in the history
  • Loading branch information
PKulkoRaccoonGang committed Aug 4, 2024
1 parent fcf84d0 commit 63d06b6
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
6 changes: 6 additions & 0 deletions scss/core/css/utility-classes.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* IMPORTANT: This file is the result of assembling design tokens
* Do not edit directly
* Generated on Tue, 31 Jan 2023 09:38:46 GMT
*/

.bg-dark {
background-color: #273F2FFF !important;
}
Expand Down
6 changes: 6 additions & 0 deletions scss/core/css/variables.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/**
* IMPORTANT: This file is the result of assembling design tokens
* Do not edit directly
* Generated on Tue, 31 Jan 2023 09:38:46 GMT
*/

:root {
--pgn-theme-interval: 8%;
--pgn-other-tooltip-opacity: 1;
Expand Down
8 changes: 7 additions & 1 deletion tokens/build-tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ const source = tokensSource ? [tokensSource] : [];

const config = {
include: [path.resolve(__dirname, 'src/**/*.json')],
fileHeader: {
customFileHeader: (defaultMessage) => [
'IMPORTANT: This file is the result of assembling design tokens',
...defaultMessage,
],
},
source,
platforms: {
css: {
Expand All @@ -39,7 +45,7 @@ const config = {
],
transforms: StyleDictionary.transformGroup.css.filter(item => item !== 'size/rem').concat('color/sass-color-functions', 'str-replace'),
options: {
showFileHeader: false,
fileHeader: 'customFileHeader',
},
},
},
Expand Down
8 changes: 4 additions & 4 deletions tokens/style-dictionary.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ StyleDictionary.registerFormat({
*/
StyleDictionary.registerFormat({
name: 'css/custom-variables',
formatter({ dictionary, options }) {
formatter({ dictionary, options, file }) {
const variables = dictionary.allTokens.sort(sortByReference(dictionary)).map(token => {
let { value } = token;
const outputReferencesForToken = token.original.outputReferences === false ? false : options.outputReferences;
Expand All @@ -106,7 +106,7 @@ StyleDictionary.registerFormat({
return ` --${token.name}: ${value};`;
}).join('\n');

return `:root {\n${variables}\n}\n`;
return `${fileHeader({ file })}:root {\n${variables}\n}\n`;
},
});

Expand All @@ -119,7 +119,7 @@ StyleDictionary.registerFormat({
*/
StyleDictionary.registerFormat({
name: 'css/utility-classes',
formatter({ dictionary }) {
formatter({ dictionary, file }) {
const { utilities } = dictionary.properties;

if (!utilities) {
Expand All @@ -144,7 +144,7 @@ StyleDictionary.registerFormat({
}
});

return utilityClasses;
return fileHeader({ file }) + utilityClasses;
},
});

Expand Down

0 comments on commit 63d06b6

Please sign in to comment.