abe33 / atom-pigments

An Atom package to display colors in project and files.
MIT License
521 stars 68 forks source link

How do I prevent Pigments from displaying colors from previously declared color variables? #455

Closed nytorq closed 4 years ago

nytorq commented 4 years ago

This isn't an issue or bug, so apologies if this I've mis-categorized this.

Over the course of 5 different front-end projects, I've declared the SCSS variable $color-primary and now in my 6th project, I'm seeing this 6th declaration of $color-primary display instances with the background-color of my previous project's $color-primary.

In short, project 5's $color-primary was blue, and I've declared project 6's $color-primary as black. Yet, Pigments is making it show up as blue.

How do I prevent this from happening? I presume this is a scope issue? Is there a way to tell Pigments to only apply colors from variables localized within the current project directory?

image

Cxarli commented 4 years ago

Short answer: You don't. Or at least not with this plugin

Long answer: Pigments was never made with the intention to do full scope analysis. In the beginning, it was basically just hex codes and such (rgba(...)), and later some support was added for variables. Less and Sass are very powerful languages, and it's possible to recursively include many files, each overwriting the same variable. Furthermore, they allow you to create functions which return colours. Several issues have asked Pigments for support (#208 #207 #79 #56 #49) but I think the best answer was here. TLDR: It would be a mess to implement this correctly with the current codebase.

Since the owner of the repo seems to have abandoned it, and I don't know enough about Atom plugins to implement it, it seems unlikely this will be fixed soon.

The alternative plugin https://github.com/thomaslindstrom/color-picker seems to implement something similar, but hasn't had any update since 2018 either. You might want to try it, but no guarantees are given.