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

API - Color: Implement hex parsing #102

Closed
bryphe opened this issue Dec 7, 2018 · 7 comments
Closed

API - Color: Implement hex parsing #102

bryphe opened this issue Dec 7, 2018 · 7 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@bryphe
Copy link
Member

bryphe commented Dec 7, 2018

We have a small Color API to parse / work with colors - it's very bare-bones at the moment, though!

One important feature we need for it is creating colors from hex-values. Some examples of cases we should be able to parse:

  • #FFF (3 element, rgb)
  • #FFFA (4 element, rgba)
  • #01010F (6 element, rgb)
  • #0101CC0F (8 element, rgb)

It'd be fine to use a library for this (I'm sure there is one existing), but the main thing is just that we can parse these hex colors and get the right output.

An API like Color.hex("#FFF") that returns a Color.t would be perfect. We should have tests covering this case, as well.

@bryphe bryphe added help wanted Extra attention is needed good first issue Good for newcomers labels Dec 7, 2018
@bryphe
Copy link
Member Author

bryphe commented Dec 7, 2018

This is a good place to start looking: https://github.com/bryphe/revery/blob/master/src/Core/Color.re

@bryphe
Copy link
Member Author

bryphe commented Dec 12, 2018

Sounds like @kitten might help us out here! 💯

@rauanmayemir
Copy link
Collaborator

What do you think about factoring out Color to be universal to some extent?

There are https://opam.ocaml.org/packages/gg/ and https://opam.ocaml.org/packages/color/, and I've been considering to base some solution off of it for Brisk. Your implementation is as close as I'd imagine it myself.

@bryphe
Copy link
Member Author

bryphe commented Dec 13, 2018

What do you think about factoring out Color to be universal to some extent?

Would be open to it, if it'd be useful!

There are https://opam.ocaml.org/packages/gg/ and https://opam.ocaml.org/packages/color/, and I've been considering to base some solution off of it for Brisk.

Cool. I didn't know about https://opam.ocaml.org/packages/color/ - that looks like exactly what we need for parsing / hex conversion. The only other thing we really have beyond that here is our list of colors contributed by @bgoscinski : https://github.com/bryphe/revery/blob/master/src/Core/Colors.re - is that something that would be useful for Brisk?

@rauanmayemir
Copy link
Collaborator

Sure, why not. I wonder if they could be upstreamed into Color or Gg, otherwise, we'd end up repeating it everywhere.

@kitten
Copy link
Contributor

kitten commented Dec 13, 2018

I'm not that experienced in dealing with Dune, so I'd be happy to leave this up to someone else if we'd like to go for https://github.com/anuragsoni/color :)

@bryphe
Copy link
Member Author

bryphe commented Dec 18, 2018

I went ahead and added the @opam/color lib 👍 (And exposed just a thin wrapper that basically shifts the API from snake case to camel case).

@rauanmayemir - @jchavarri had an idea that is relevant to the sharing out of these sorts of APIs. He drafted a proposal here: revery-ui/reason-reactify#35

I think it's a really cool idea - having some set of basic primitives that could be used between projects. Wouldn't it be neat if you could create a custom component that could be used in both revery and brisk, for example? Would be great to get your feedback on that issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants