A slightly better color picker for CraftCMS
by Michael Rog
https://topshelfcraft.com
The Hue fieldtype works almost identically to Craft's native Color field, with some added bonuses:
- You can directly edit the color code as text.
- You can specify a default color in the field settings.
- You can clear (i.e. un-set) field values
- You can set the default color to be empty.
- The
ColorModel
gives you access to nice helper variables.
When you access a Hue field in your templates, its value will either be null
(if there is no color set), or a ColorModel.
A ColorModel has the following methods/properties:
Returns the string representation of the color in hexidecimal format, including the #
at the beginning.
Returns the string representation of the color in RGB format, i.e. "0,255,0"
for blue.
Returns the numeric value of the red channel, from 0-255.
Returns the numeric value of the green channel, from 0-255.
Returns the numeric value of the blue channel, from 0-255.
Craft 2.5+ and PHP 5.4+
Please open a GitHub Issue, submit a PR to the dev
branch, or just email me to let me know.
- Plugin development: Michael Rog / @michaelrog
- Plugin development: Steve V / @dubcanada