Problem/Motivation
Based on: https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb
It's recommended to use rgb(), not rgba(), also for colors with transparency.
Steps to reproduce
Configure formatter to display value as RGB. For fields with transparency enabled, it uses rgba().
Proposed resolution
Replace colors in rgba (e.g. rgba(0, 0, 0, 0.5)) with colors in rgb (e.g. rgb(0, 0, 0 / 0.5)).
| Comment | File | Size | Author |
|---|---|---|---|
| #8 | AfterPatch.png | 19.57 KB | anirudhsingh19 |
| #8 | BeforePatch.png | 20.78 KB | anirudhsingh19 |
| #6 | color_field-3542956-6.patch | 834 bytes | gugalamaciek |
Issue fork color_field-3542956
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
gugalamaciek commentedComment #3
gugalamaciek commentedComment #4
gugalamaciek commentedComment #5
gugalamaciek commentedComment #6
gugalamaciek commentedReplace comas with spaces, so now this is returned:
rgb(0 0 0)
rgb(0 0 0 / 0.5)
Comment #7
anirudhsingh19 commentedreviewing this!
Comment #8
anirudhsingh19 commentedThe patch works fine. Please provide a MR as patches are not recommended anymore.
Comment #11
macsim commentedApplied the patch from #6 and updated the PHPUnit functional tests accordingly.
The
ColorRGB::toString()method now uses the modern CSS color syntax:rgb(r g b / a)when opacity is enabled and the value is not 1.0rgb(r g b)when opacity is disabled or equals 1.0 (fully opaque)All assertions in
ColorFieldFormatterTestandColorFieldFormatterTokenTesthave been updated to reflect the new output format.eslint warnings are not related to those changes
Comment #12
mandclu commentedComment #14
mandclu commentedThanks for everyone's work here. Merged into a new 3.1.x branch.