question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support nested maps in sass:map functions

See original GitHub issue

Edited 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:closed
  • Created 8 years ago
  • Comments:36 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
nex3commented, Sep 22, 2020

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.

1reaction
mirisuzannecommented, Apr 12, 2020

There’s a formal proposal in development. See the links directly above.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found