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

Add on option to quote keys #5

Closed
vitto opened this issue Jul 31, 2019 · 2 comments
Closed

Add on option to quote keys #5

vitto opened this issue Jul 31, 2019 · 2 comments

Comments

@vitto
Copy link

vitto commented Jul 31, 2019

It would be nice to add an option to wrap key name between quotes:

What the module does now:

$colors: (
  brand: (
    primary: #0044d7,
    secondary: #b40038
  ),
  grey-scale: (
    black: rgb(0, 0, 0),
    abbey: rgb(77, 77, 77),
    boulder: rgb(121, 121, 121),
    star-dust: rgb(153, 154, 156),
    silver: rgb(187, 189, 191),
    mercury: rgb(230, 230, 230),
    haze: rgb(246, 246, 246),
    white: rgb(250, 250, 250)
  ),
  status: (
    disabled: rgb(187, 189, 191),
    error: rgb(230, 32, 68),
    info: rgb(0, 181, 184),
    neutral: rgb(77, 77, 77),
    success: rgb(133, 195, 61),
    warning: rgb(230, 169, 53)
  )
);

What it could do:

$colors: (
  "brand": (
    "primary": #0044d7,
    "secondary": #b40038
  ),
  "grey-scale": (
    "black": rgb(0, 0, 0),
    "abbey": rgb(77, 77, 77),
    "boulder": rgb(121, 121, 121),
    "star-dust": rgb(153, 154, 156),
    "silver": rgb(187, 189, 191),
    "mercury": rgb(230, 230, 230),
    "haze": rgb(246, 246, 246),
    "white": rgb(250, 250, 250)
  ),
  "status": (
    "disabled": rgb(187, 189, 191),
    "error": rgb(230, 32, 68),
    "info": rgb(0, 181, 184),
    "neutral": rgb(77, 77, 77),
    "success": rgb(133, 195, 61),
    "warning": rgb(230, 169, 53)
  )
);

Without quotes, the maps seems to work properly until I try to get quoted keys like 'black', 'silver' or 'white':

.selector {
  background-color: map-get($grey-scale, black); // returns #000
}

.selector {
  background-color: map-get($grey-scale, 'black'); // returns null
}

For choosen coding standard and choosen linting reasons, I cannot change all the files by removing the quotes, so I ask you if you could add the option to export maps with it's SASS quotes standard, would it be possible?

The problem is also listed on SASS site ⚠️Heads up! paragraph.

@rlapoele
Copy link
Owner

rlapoele commented Aug 1, 2019

Hi again Vitto,
I'll come-up with an upgrade sometimes in the future regarding the possibility to quote the keys as you mentioned/suggested.
This should solve the issue you are describing above.
Note that I've never faced such issue myself before but this could be because:

  • I use node-sass only.
  • I always make sure to use a key value exactly similar to what is in the map; if in the map, I've used "black", then I make sure to map-get it using also "black". The same would go if I were to leverage just black.

Anyway - good luck with what you are doing and hopefully I'll find a bit time to implement what you've suggested regarding the keys (and something for values like "Arial, serif"...)
Regards.

@rlapoele
Copy link
Owner

rlapoele commented Aug 2, 2019

The option to quote (single or double) keys has been added.
use the --k='dq' command line option to get double-quoted sass map keys.
You can get single quotes using --k='sq'.

Similar option is available for the values using the --v (the same option values apply such as 'auto' (no quotes), 'sq' and 'dq'.

Both new options are part of the 1.4.0 release.

@rlapoele rlapoele closed this as completed Aug 2, 2019
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

No branches or pull requests

2 participants