Support nested maps in sass:map functions
See original GitHub issueEdited by @nex3
@lunelson project sass-list-maps has support for nested list maps, using the map-get-z function
.
https://github.com/lunelson/sass-list-maps
The following example says it all:
$list-map-z: (
alpha (
beta (
gamma 3
)
)
);
.demo {
out: map-get-z($list-map-z, alpha); // -> ( beta ( gamma 3 ) )
out: map-get-z($list-map-z, alpha, beta); // -> ( gamma 3 )
out: map-get-z($list-map-z, alpha, beta, gamma); // -> 3
}
FACT: Up to a point, even when using maps extended naming conventions come into play. Using map-get-z
we can actually use structure to categorize versus naming conventions. I vote for structure every time.
$carousel: (
color (
header (
border gray,
)
)
);
$side-nav: (
bg gray,
color (
hover (
search yellow,
home red,
filter blue
)
)
);
block {
color: map-get-z($side-nav, color, hover, filter);
}
block {
border-color: map-get-z($carousel, color, header, border);
}
I don’t mind using the plug-in, but I think that this is a feature that Sass should support natively.
Issue Analytics
- State:
- Created 8 years ago
- Comments:36 (10 by maintainers)
Top Results From Across the Web
sass:map
Sass libraries and design systems tend to share and override configurations that are represented as nested maps (maps that contain maps that contain...
Read more >Advanced Use of Sass Maps - ITNEXT
Improve use of Sass Maps by using some functions. Make your code clean, ... Sass Function — Check if nested map has a...
Read more >How to use map-deep-get in sass - css - Stack Overflow
This map-deep-get function let's you acces as deeply nested values as you want and can also be used as a regular map-get function....
Read more >Sass Maps vs. Nested Lists - SitePoint
Maps are more powerful than lists because of they use key-value pairs. The additional Sass map functions provide useful ways to find data...
Read more >Deep Get/Set in Maps | CSS-Tricks
When working on complex Sass architectures, it is not uncommon to use ... Deep set function to set a value in nested maps...
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 FreeTop 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
Top GitHub Comments
I forgot to mention: since the proposal was accepted and the blog post soliciting comments published on 16 September, the countdown has begun for public comment. I’ll give it two weeks with the option of going longer if there’s substantial discussion. If there isn’t, on 30 September it will be locked in and we’ll ship the feature in Dart Sass.
There’s a formal proposal in development. See the links directly above.