Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stylus: Coerce colors etc #59

Open
jescalan opened this issue Dec 15, 2014 · 9 comments
Open

Stylus: Coerce colors etc #59

jescalan opened this issue Dec 15, 2014 · 9 comments
Labels

Comments

@jescalan
Copy link
Owner

Right now if you want to pass a color into stylus, it needs to pull stylus' class and initialize a custom object with an rgba array. This is an unintuitive pain in the ass. Luckily, we can definitely fix this and make stylus take any normal css color, then just convert it to the stylus format before passing to the adapter. This would probably be a useful addition for a lot of people 😀

@Munter
Copy link
Contributor

Munter commented Dec 15, 2014

We wrote a pretty good color parser/library back in the day that might make this easier for you: https://github.com/One-com/one-color

@jescalan
Copy link
Owner Author

This looks fantastic @Munter -- thank you! Definitely will take advantage of this 😀

@notslang
Copy link
Contributor

How do you propose that we pass a color into accord, if not as a stylus color node?

@jescalan
Copy link
Owner Author

I'd propose taking accepting valid css color declaration (hex, rgba, etc), then having accord do the conversion in the background to a stylus color node.

@notslang
Copy link
Contributor

Passed as a string? Or as some type of special object?


Sent from Mailbox

On Thu, Dec 18, 2014 at 3:46 PM, Jeff Escalante [email protected]
wrote:

I'd propose taking accepting valid css color declaration (hex, rgba, etc), then having accord do the conversion in the background to a stylus color node.

Reply to this email directly or view it on GitHub:
#59 (comment)

@jescalan
Copy link
Owner Author

String

@notslang
Copy link
Contributor

Then how would we pass a string that's in the same format as a color without it being turned into a color object? Or a string that may or may not be in the same format as a color?

@jescalan
Copy link
Owner Author

We would assume that if you are passing a css color, you want it to be a color, not a string. I feel like this is a very fair assumption that will comprise 99.9% of cases, so I'm comfortable with affording most people lots of extra convenience at the cost of maybe one crazy edge case. I'd rather make a workaround for people that do not want this behavior than the other way around. And I'm honestly ok with not making one at all until we receive a complaint, which I highly doubt we will.

@janwirth
Copy link

I recently used this library which did all the coercion for me.
https://github.com/pressly/stylus-coerce
Maybe this info helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants