atom-pigments
atom-pigments copied to clipboard
map_get support
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?
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.
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
}
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!
Dear god, please this. I use functions to get colors from different maps.
Sass Map
Function - pigment color is wrong :(
@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);
}
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 On second look I have the very same thing ;-)
You simply illustrated well the issue at hand with visualization of SASS mapped colors.
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.