getgrav / getgrav/grav-plugin-admin
Colorpicker format and validation
- Dominant language
- PHP
- Stars
- 377
- Forks
- 225
- Avg merge
- 11h 51m
- Merged PRs (30d)
- 4
Description
With Admin v1.10.30.1, the [colorpicker](https://learn.getgrav.org/17/forms/blueprints/fields-available#colorpicker-field) seemingly supports two formats: Hex and RGBA, but not RGB.
For example, when a blueprint uses the color `rgb(255, 138, 128)`, it renders fine:

When you click the field, the colorpicker-composes interprets it as a hex-value and transforms it into `#ff8a80`:

If you then click the transparent-button, it gets interpreted back to RGB with an alpha-channel set to 0:

Whereas it should be `rgba(255, 138, 128, 1.00)`. But why isn't RGB simply supported? With a simple list of colors, like
```yaml
colors:
- name: White
value: "rgb(250, 250, 250)"
- name: Red
value: "rgb(255, 138, 128)"
- name: Orange
value: "rgb(255, 209, 128)"
```
these will not fit the pattern-validation, and when trying to save settings in a blueprint it will practically go through each one, transforming them to the nearest Hex. Is the solution #921 not sufficient?
Contributor guide
Research direction
Start with the colorpicker field documentation and reproduce the blueprint example using rgb(...) values. Compare the current behavior with the solution referenced in #921, then verify that RGB values pass validation, are not converted to hex, and transparent values use the expected rgba(..., 1.00) form.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, php
- Domain
- backend, frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100