Adds color utilities to saltcorn.
Edit a color using your browser's color picker or by typing in any valid (or slightly invalid) CSS color. Choose whether to allow transparency or only opaque colors.
- Show as text - view a color value just as a text hex code
- Show as color swatch - shows a small rounded square in your color
- Show as text and color swatch - shows the color swatch and text value together
saltcorn-colors adds color functions for use in calculated fields and js events:
toHex(color) //returns a 6 character hex string for the provided color string.
toHex("red") // "#ff0000"
toHex("#fc0") // "#ffcc00"
toHex("rgb 200 150 250") // "#c896fa"
toHex("6495edaf") // "#6495ed"
toHex("this is not a color") // null
//supports many other formats not listed here.
//if an invalid color is passed, returns null.
//if a color with transparency is passed, returns the opaque version.
toHex8(color) //returns an 8 character hex string for the provided color string.
toHex8("red") // "#ff0000ff"
toHex8("#fc0") // "#ffcc00ff"
toHex8("rgb 200 150 250") // "#c896faff"
toHex8("6495edaf") // "#6495edaf"
toHex8("this is not a color") // null
//supports many other formats not listed here.
//if an invalid color is passed, returns null.