joshuanianji / github-language-colors

A collection of all of Github's language colours in Elm
https://package.elm-lang.org/packages/joshuanianji/github-language-colors/latest/GithubColors
MIT License
0 stars 0 forks source link

Github Language Colors

Test Release version

A collection of all of Github's language colors in Elm. Automatically updated using ozh/github-colors, and autogenerated by elm-codegen.

Usage

See this in action on Ellie

import Html exposing (Html)
import Html.Attributes exposing (style)
import GithubColors

main : Html msg
main =
    Html.div
        [ style "color" GithubColors.elm.hex ]
        [ Html.text "Elm" ]

A full list of languages can be found in the docs.

Colors

Each variable in the GithubColors holds the color information of a single Github language.

Github does not have colors for all languages! For the languages with no colors, I've defaulted to "#ccc", which is what Github does in most cases. You can programmatically check if a language has a color by using the .hasColor field.

Each variable is a Color type that looks like the following:

type alias Color =
    -- an elm-ui color
    { elmui : Element.Color
    -- an elm-color color
    , color : Color.Color
    -- a hex string (e.g. "#60B5CC")
    , hex : String
    -- an rgb tuple
    , rgb : ( Int, Int, Int )
    -- false if the language does not have a color
    , hasColor : Bool
    }

Variable Naming

Language names are converted to lowercase and most non-alphanumeric characters are replaced by underscores except when they are relevant to the name (e.g. c++, f#). Languages starting with a number gets prefixed by "lang_".

E.g.

If you find any issues with the language naming, please submit an issue or a PR!

Run Locally

pnpm i && pnpm get-colors
pnpm dev