atom-pigments icon indicating copy to clipboard operation
atom-pigments copied to clipboard

map_get support

Open Julix91 opened this issue 7 years ago • 8 comments

I'd like to have my colours displayed, even if they're stored in an array - Things like: map_get($theme-colors,button-color)

Is that possible?

Julix91 avatar May 16 '17 20:05 Julix91

Of what language is that a feature? I'm not sure if it is in scope of Pigments to interpret all theme files to find arrays, but I'll let that decision over to abe33.

Cxarli avatar May 20 '17 14:05 Cxarli

Yes, +1 for this. I do believe @Julix91 is referring to Sass; at least that's what I would want.

Here's an example scenario expanding on @Julix91's request for more clarification:

$primary: #34495E;

$map: (
   orange: #FFA500,
   indigo: #4B0082,
   default: $primary
);

.example {
   color: map-get($map, default);
   // 'map-get($map, default)' is highlighted
}

It would also be nice for the scope to go even further (using the previous example):

@function color($var) {
   @return map-get($map, $var); 
}

.example {
   color: color(default);
   // 'color(default)' is highlighted
}

dmbdesignpdx avatar May 22 '17 23:05 dmbdesignpdx

Yes, that's exactly what I was talking about. I didn't consider that obviously pigments are useful across many languages and thus support for SASS arrays might be out of scope. If that's the case, fair enough! - Thanks for this awesomely useful plugin!

Julix91 avatar May 22 '17 23:05 Julix91

Dear god, please this. I use functions to get colors from different maps.

Sass Map screen shot 2017-07-13 at 7 28 45 pm

Function - pigment color is wrong :( screen shot 2017-07-13 at 7 30 14 pm

jameelmoses avatar Jul 13 '17 23:07 jameelmoses

@jameelmoses What does your @function look like?

It should be something like what follows:

@function sitecolor ($sitecolor, $tone: 'base') {
      @return map-get(map-get($sitecolors, $sitecolor), $tone);
}

prefonty avatar Jul 14 '17 13:07 prefonty

Yep. It's below. It compiles correctly. Pigments just doesn't pull the color in. It shows orange from the color keyword instead of the assigned hex value.

@function site-color($color, $tone: base) {
  @return map-get(map-get($sitecolors, $color), $tone);
}

jameelmoses avatar Jul 14 '17 13:07 jameelmoses

@jameelmoses On second look I have the very same thing ;-)

You simply illustrated well the issue at hand with visualization of SASS mapped colors.

prefonty avatar Jul 14 '17 14:07 prefonty

While I love this feature, it seems out of scope for Pigments to me. These functions can be spread over multiple files and multiple directories, and could be nested a lot. I'm afraid it's too Sass-specific to be implemented in Pigments. But, as I said before, it's eventually up to Abe33 to decide.

Cxarli avatar Jul 24 '17 12:07 Cxarli