Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#13370 closed defect (fixed)

dijit.ColorPalette needs better support for transparent

Reported by: rmaccracken Owned by:
Priority: high Milestone: 1.7
Component: Dijit Version: 1.6.1
Keywords: ColorPalette transparent Cc: maccrack@…, nic, elazutkin
Blocked by: Blocking:


I have written an SVG editor and need "transparent" as one of my colors in the palette and would like its value to be "none" rather than a hex value of #ffffff or #000000.

There are a few problems in trying to implement this:

1) Even though the dijit._PaletteMixin provides a "dyeClass" member to override the dyeClass, dijit.ColorPalette provides its own so that there is not a simple way to override it.

2) dojo.Color.named.transparent is set to [255,255,255] (or dojo.config.transparentColor) in dojo/_base/Color.js, but is then overridden by dojo/colors.js and changed to [0,0,0,0]. I'm not sure why this happens, but seems a bit strange. In any case, the toHex function does not distinguish transparent from black/white. I think it makes sense to return "none" as a special case for transparent.

3) transparent is not available in the localization for colors

Change History (5)

comment:1 Changed 3 years ago by bill

  • Cc nic elazutkin added

The "transparent" color is originally from [9659] (which should have added it to the NLS files) but the discrepancy appears in [18795]. Looks like the entry in dojo/colors.js should be removed now that "transparent" has been added to dojo/_base/Color.js. I don't know which setting is better, the first three numbers seem meaningless and neither file has an opacity setting for transparent.

As for dijit I can add a getDyeClass() method to dijit.ColorPalette (that returns the subclassed dijit._Color constructor), or perhaps better a getDye() method to _PaletteMixin that returns an instance. (I'm thinking that the "dyeClass" member was a mistake given that it doesn't allow enough customization for dojo.ColorPalette to work, let alone your extension.) Any opinions there?

comment:2 Changed 3 years ago by bill

(In [25750]) Remove duplicate and conflicting definition of "transparent". Add "transparent" to NLS message file. Using [0,0,0,0] for transparent as per the CSS3 Color Module spec, and dojo/tests/colors.js unit test.

Refs #3652, #6399, #13370.

comment:3 Changed 3 years ago by bill

  • Resolution set to fixed
  • Status changed from new to closed

(In [25752]) Provide factory for creating "dye" instances for each cell, so it's easier to subclass. Fixes #13370 !strict.

comment:4 Changed 3 years ago by bill

  • Milestone changed from tbd to 1.7

comment:5 Changed 3 years ago by bill

In [26060]:

Fix regression from [25752] where ColorPalette colors wouldn't show up in high contrast mode. Fixes #13599, refs #13370 !strict.

Note: See TracTickets for help on using tickets.