Giter VIP home page Giter VIP logo

elm-color's Introduction

elm-color

An Elm package to work with web colors.

Example

You can find this example at example/src/Main.elm.

Usage

Build using different constructors, or manipulate values, i.e., change the lightness of a color in the HSL space.

colors : List Color
colors =
    [ hsl 194 0.49 0.14
    , fromHexUnsafe "#06A77D"
    , rgb 0.96 0.976 0.996
    , rgb255 122 137 194
    ]


colorPalette : List Color
colorPalette =
    fromPalette "https://coolors.co/40f99b-61707d"


green : Color
green =
    hsl 164 0.93 0.34


fontColor : Color
fontColor =
    if isLight green then
        black

    else
        white


viewHtml : Html msg
viewHtml =
    Html.div
        [ style "background-color" (Color.toCssString green)
        , style "color" (Color.toCssString fontColor)
        ]
        [ Html.text (toCssString green) ]


{-| Elm-UI example

For elm-ui see <https://package.elm-lang.org/packages/mdgriffith/elm-ui/latest/>

-}
view : Element msg
view =
    el
        [ Element.Background.color (toElementColor green)
        , Element.Font.color (toElementColor fontColor)
        ]
        (text (toCssString green))


{-| Helper to convert to elm-ui color
-}
toElementColor : Color -> Element.Color
toElementColor =
    Element.fromRgb << Color.toRgba

Notes

Drop in replacement for avh4/elm-color

This package is a new implementation from the ground up with many more features. However, it shares the same api as avh4/elm-color. Since that package doesn't seem to be actively maintained anymore, you can use this new package as a drop-in replacement.

Readme created with elm-generate-readme

To make sure the examples work, this readme is compiled with elm-generate-readme :)

elm-color's People

Contributors

escherlies avatar

Stargazers

Pedro Lara Campos avatar Christopher Ribeiro avatar

Watchers

 avatar

elm-color's Issues

add darkGrey and other avh4/elm-color colors

Looks like these are missing, there's just black and white:

, red, orange, yellow, green, blue, purple, brown
, lightRed, lightOrange, lightYellow, lightGreen, lightBlue, lightPurple, lightBrown
, darkRed, darkOrange, darkYellow, darkGreen, darkBlue, darkPurple, darkBrown
, white, lightGrey, grey, darkGrey, lightCharcoal, charcoal, darkCharcoal, black
, lightGray, gray, darkGray

would be nice to have these as my code that uses avh4/elm-color depends on them.

fromHex fails

I tried this code and it was not working ๐Ÿค”

Color.fromHex "#1a79cb"

Defaulted to the transparent color...

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.