getgrav / getgrav/grav-plugin-admin

Colorpicker format and validation

Open
#2,256 0 comments 0 reactions 0 assignees View on GitHub
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:

![image](https://user-images.githubusercontent.com/974717/159082561-daa0cb3a-97f1-4552-8667-6a1d955afd7f.png)

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

![image](https://user-images.githubusercontent.com/974717/159082677-04be7bc9-dc8b-4c17-9975-b07f171c208e.png)

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

![image](https://user-images.githubusercontent.com/974717/159082890-751c573a-8c4d-44b4-976e-89a073833358.png)

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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.