Closed (fixed)
Project:
Color Field
Version:
7.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
7 May 2013 at 16:08 UTC
Updated:
24 Sep 2015 at 12:45 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
targoo commentedFirst of all thanks for the interest in this module!
I think we should always store the value in hex6 but we could have helpers to convert from one format to another one.
HEW6 to RGB
HEX6 to HSL...
I might change the schema though to record the transparency property.
Comment #2
StGalant commentedMy "alpha hack" for CSS Declaration:
For rgb column and "Plain Text" widget's color field i changed the length to 22 and disabled validation of its value.
Now can enter any text such as "rgba(255,255,255,0.75)".
Rough but simple :)
Comment #3
DaneMacaulay commentedThere much to be gained here allowing rgba as these values can be used to provide inline styles for user editable content. As StGalant points out its ez. Perhaps we can maintain the validation function, but build it to validate more intelligently.
Comment #4
azuledu commentedAny news about supporting alpha values? It would be a great feature!
Thanks.
Comment #5
inteja commentedDitto. Would be great to have.
Comment #6
inteja commentedThis may help some people when it comes to alpha values: https://drupal.org/comment/8308885#comment-8308885
Comment #7
targoo commentedThanks inteja for the feedback.
I will be working soon on the alpha support.
Cheers,
Comment #8
axe312 commentedHey there,
here is a patch which introduces a new field type: color field with alpha. It supports plain text and the spectrum selector widget. Please review and test!
Comment #9
yannickooThanks man for that patch! The regex is crazy and it works great (customize it and see)!
I was confused about your widget description
Format rgba(255, 255, 255, 0.99). Why you are using that syntax instead of the syntax fromcolor_field_field_widget_info(which isrgba(255, 255, 255, 1))? I "fixed" that in the attached patch.Another mentionable thing is that you are using strings when exposing booleans to the JavaScript:
$settings['show_alpha'] = 'false';and$settings['show_alpha'] = 'true';. This was also fixed in the patch.Sorry for that ugly code comments but Dreditor is not working since drupal.org moved to www.drupal.org :/
Comment #10
axe312 commentedThx for the review and the fixed patch. Had no hussle to apply it again :)
I've used
rgba(255, 255, 255, 0.99)to make clear that it is supporting alpha values with the precision of 2. I took this precision, because more is very unusual and the tinycolor library used by the spectrum color picker also uses 2 decimals after the dot.Unfortunately, the w3c definition of the alpha value does not limit the precision, even numbers above 1 and below 0 are valid:
http://www.w3.org/wiki/CSS3/Color/opacity#alphavalue
Comment #11
davidwbarratt commentedWhy are the rgba values being stored in a single varchar column? Why not have 4 columns (3 int, 1 decimal)? seems like it would be better database design, also have less characters and less chance for something random to get inserted into the database.
Thanks!
Comment #12
yannickooNice input David!
Comment #13
targoo commentedI'm very keen to keep the color into 2 DB columns (color and opacity). See more on http://www.w3.org/TR/css3-color/#color
The color should use the 6 RGB hex values and the opacity will just be a float.
Why I like the 6 RGB hex values format:
1) HTML5 is using the same format.
The value is a string representing a color which is exactly seven characters long, consisting of the following parts, in exactly the following order:
A "#" character.
Six characters in the range 0–9, a–f, and A–F.
More on http://www.w3.org/TR/html-markup/input.color.html
2) Most people are really use to the well know color format #F0F8FF, #7FFF00 and you know what they represent as soon as you see them.
3) Migration from before and after the Alfa implementation will be easier.
4) Validation of the 6 RGB hex values is also trivial: preg_match('/^#[a-f0-9]{6}$/i
5) HEX is more compact.
6) Older browsers like IE5 doesn’t support rgb :-p [jokes]
Comment #14
targoo commentedGood news folks...
Branch 7.x.2.x now support the opacity value.
Give it a try and report any issues.
Not yet ready for production but very close now.
We should have a beta version within a month...
Comment #15
yannickooCool!
So the current version adds a new field setting:
This is how the widget looks like:
And it seems like the field formatters does not support this right now, I think this is what targoo means with "but very close now" :)
Comment #16
targoo commentedNo I am working on the formatters but that easier than the widget ;-)
Thanks for the first tests. Much appreciate.
Did you migrate from 7.x-1.x ? No issue regarding the migration ?
Comment #17
yannickooI checked
7.x-2.xbranch on simplytest.me, sorry :DComment #18
yannickooComment #19
targoo commentedHi,
7.x-2.x supports now the latest spectrum widget and the color opacity. spectrum requires jQuery 1.7.2 so make sure to upgrade you jQuery.
Thanks,