Strings get converted to unquoted strings in scss & css
See original GitHub issueHey,
I noticed that all strings end up being unquoted, for example:
textCase: {
value: "uppercase"
}
Will show up in the css file as:
--body-text-case: uppercase;
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Strings - Sass
You can convert a quoted string to an unquoted string using the string.unquote() function, and you can convert an unquoted string to a...
Read more >SASS string to "non string" - css - Stack Overflow
I am running into an issue where map-get() is not able to find the appropriate value if a quoted string is used for...
Read more >Working With Strings In Sass - Vanseo Design
That's how it generally works. The exception is interpolation ( #{} ), where all strings will become unquoted. [code type=css] $headline- ...
Read more >Sass String Functions - W3Schools
Well organized and easy to understand Web building tutorials with lots of examples of how to use HTML, CSS, JavaScript, SQL, PHP, Python,...
Read more >Casting a string to a number in Sass - Kitty Giraudel
Needless to say I found a solution! Even better, I found a solution to convert a string into a valid CSS length you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hey @tonyjwalt I think this is an interesting solution for me.
@dbanksdesign to clarify where I am coming from.
I am currently working on a figma design token export plugin. I would like to ideally export a json file that can be converted by style-dictionary without any additional magic from my side.
CTI seems a bit limiting, as by default in Figma things like font styles include sizes, fonts and other things. If I understand you correct, I would have to include the “font-family” under the specific category
content
while the fontSize would be under the categorysize
. Is this correct?Currently I have a json (before trying to transform it for style-dictionary) that looks like this:
I think it would make sense to have this converted into tokens like:
Does this make sense? Or am I missing something here?
CSS seemed to be an odd one for us because some strings cannot be wrapped in quotes, while it’s required for others. On my team we thought this behavior was a format thing, so we built a solution into our custom formatter. You can see that in PR 428 in the formatter file on line 32.
We applied a solution similar to what @dbanksdesign recommended, but used
data-type
on theattributes
object instead of justtype
. We felt it was descriptive of an attribute of the token and this also allowed us to mix and match a token’stype
with the type of data used to define it.As @dbanksdesign said, there are several ways to solve it. I just thought I’d share what we did if it helps.