Giter Club home page Giter Club logo

Comments (12)

rtfeldman avatar rtfeldman commented on August 22, 2024

This should be pretty straightforward.

We just need to add a color : Color.Color field such that you can ultimately do this in elm-repl:

> (Css.rgb 22 23 24).color
RGBA 22 23 24 1 : Color.Color

This would mean changing color : Compatible to colorValue : Compatible to avoid the namespace conflict. After that, we'll want some sort of mapColor function like so:

mapColor : (Color.Color -> Color.Color) -> Css.Color -> Css.Color

> mapColor (\elmCoreColor -> Color.rgb 1 2 3) Css.rgba 99 88 77 0.5
{ value = "rgb(1, 2, 3)", colorValue = Compatible, warnings = [], color = RGBA 1 2 3 1 }

We could just take the resulting Color.Color value returned from mapColor's mapper function, store the new Color.Color in the record, and update the record's value based on the RGBA representation of the Color.Color (or possibly just go rgb in the specific case where the alpha value is 1).

from elm-css.

mdgriffith avatar mdgriffith commented on August 22, 2024

Just fyi, I finished the initial version of the color mixing library:
http://package.elm-lang.org/packages/mdgriffith/elm-color-mixing/1.0.2/

from elm-css.

rtfeldman avatar rtfeldman commented on August 22, 2024

Awesome! 🎉

from elm-css.

chaughawout avatar chaughawout commented on August 22, 2024

I'll take a stab at this over the next few days.

from elm-css.

chaughawout avatar chaughawout commented on August 22, 2024

So here's what I have after a couple hours of tinker arounding:

mapColor : (Color.Color -> Color.Color) -> Color -> Color
mapColor mapper cssColor =
    let
        { red, green, blue, alpha } =
            Color.toRgb << mapper
    in
        { cssColor | colorValue = Compatible, red = red, green = green, blue = blue, alpha = alpha }

This doesn't work because mapper needs an additional argument. I'm relatively new to Elm, but I think this fits the general idea of the mapColor function, but I'm missing something crucial. If anyone can point out what I'm doing wrong here, that would be really helpful.

Also, this issue is really old and I noticed #167 was closed already. Is this issue relevant still?

from elm-css.

kuon avatar kuon commented on August 22, 2024

Any update on this? Color manipulation is the thing missing from elm-css to use it over sass.

from elm-css.

rtfeldman avatar rtfeldman commented on August 22, 2024

I started work on something similar on a branch...no ETA yet though. 🙂

from elm-css.

kuon avatar kuon commented on August 22, 2024

If I can help in any way, tell me.

from elm-css.

kuon avatar kuon commented on August 22, 2024

Btw, if anybody wants to chime into mdgriffith/elm-color-mixing#3 for the preferred syntax.

from elm-css.

mthadley avatar mthadley commented on August 22, 2024

Just out of curiosity, what is the status of this now?

I recently was converting over some Sass styles to elm-css and realized that I didn't have a way of translating over the color mixing that I had.

from elm-css.

mikolajpp avatar mikolajpp commented on August 22, 2024

This feature would be very useful: currently I need to keep duplicate
colors for style-elements and Css which I use to style foreign app.

from elm-css.

rtfeldman avatar rtfeldman commented on August 22, 2024

Unfortunately this won't work out anymore based on the new "do everything at runtime" strategy. For performance reasons we'll be compiling directly to strings rather than keeping runtime metadata around like colors. So accessing the colors would require something like parsing the compiled CSS string, which doesn't sound like a good idea.

from elm-css.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.