saltcorn-colors

0.4.0 • Public • Published

saltcorn-colors

Saltcorn MIT license

Adds color utilities to saltcorn.

Color Picker

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.

Screenshot from 2022-03-07 10-31-00

Show Color

  • 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

Screenshot from 2022-03-07 10-28-36

Color Functions

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.

Readme

Keywords

none

Package Sidebar

Install

npm i saltcorn-colors

Weekly Downloads

27

Version

0.4.0

License

MIT

Unpacked Size

33.8 kB

Total Files

7

Last publish

Collaborators

  • kevin8181