-
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
feat: add support for !default in SCSS variables format #359
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,7 +40,14 @@ function fileHeader(options, commentStyle) { | |
|
||
function variablesWithPrefix(prefix, properties, commentStyle) { | ||
return properties.map(function(prop) { | ||
var to_ret_prop = prefix + prop.name + ': ' + (prop.attributes.category==='asset' ? '"'+prop.value+'"' : prop.value) + ';'; | ||
var to_ret_prop = prefix + prop.name + ': '; | ||
to_ret_prop += (prop.attributes.category==='asset' ? '"'+prop.value+'"' : prop.value); | ||
|
||
if (prop.themeable === true) { | ||
to_ret_prop += ' !default'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function, variablesWithPrefix, is used to generate less and CSS variables as well. Would this addition break those formats? We might need to rethink this function... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great catch. I assumed it was just shared between the different Sass formatters so that's my bad. It would definitely break both of those other formats without some more work. I could add an additional argument to this function to output Sass-specific properties like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I took a stab at updating the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey all, I'm working on adding a custom transform for my DS for this feature and found an edge case with my stuff that I thought I would share because It looks like you might run into the same issue here with the current code. The edge case is when I have this:
It outputs this:
The |
||
} | ||
|
||
to_ret_prop += ';'; | ||
|
||
if (prop.comment) { | ||
if (commentStyle === 'short') { | ||
|
@@ -175,14 +182,16 @@ module.exports = { | |
}, | ||
|
||
/** | ||
* Creates a SCSS file with variable definitions based on the style dictionary | ||
* Creates a SCSS file with variable definitions based on the style dictionary. | ||
* | ||
* Add `!default` to any variable by setting a `themeable: true` property in the token's definition. | ||
* | ||
* @memberof Formats | ||
* @kind member | ||
* @example | ||
* ```scss | ||
* $color-background-base: #f0f0f0; | ||
* $color-background-alt: #eeeeee; | ||
* $color-background-alt: #eeeeee !default; | ||
* ``` | ||
*/ | ||
'scss/variables': function(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.
We don't need
return done();
here, that is used if the test has some asynchronous code which we do for testing scss/less validity.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.
Good to know! I should have looked more closely at what that was for in the other test.
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.
This has been resolved.