mirror of
https://github.com/ToolJet/ToolJet
synced 2026-05-24 09:28:31 +00:00
Fixes bug that prevented alpha value from being set for color picker (#1814)
This commit is contained in:
parent
21a20bfd78
commit
3a6d4e5b5e
1 changed files with 10 additions and 1 deletions
|
|
@ -16,6 +16,15 @@ export const Color = ({ param, definition, onChange, paramType, componentMeta })
|
||||||
const paramMeta = componentMeta[paramType][param.name] || {};
|
const paramMeta = componentMeta[paramType][param.name] || {};
|
||||||
const displayName = paramMeta.displayName || param.name;
|
const displayName = paramMeta.displayName || param.name;
|
||||||
|
|
||||||
|
const decimalToHex = (alpha) => {
|
||||||
|
let aHex = Math.round(255 * alpha).toString(16);
|
||||||
|
return alpha === 0 ? '00' : aHex.length < 2 ? `0${aHex}` : aHex;
|
||||||
|
};
|
||||||
|
const handleColorChange = (color) => {
|
||||||
|
const hexCode = `${color.hex}${decimalToHex(color?.rgb?.a ?? 1.0)}`;
|
||||||
|
onChange(param, 'value', hexCode, paramType);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="field mb-3">
|
<div className="field mb-3">
|
||||||
<ToolTip label={displayName} meta={paramMeta} />
|
<ToolTip label={displayName} meta={paramMeta} />
|
||||||
|
|
@ -26,7 +35,7 @@ export const Color = ({ param, definition, onChange, paramType, componentMeta })
|
||||||
<SketchPicker
|
<SketchPicker
|
||||||
onFocus={() => setShowPicker(true)}
|
onFocus={() => setShowPicker(true)}
|
||||||
color={definition.value}
|
color={definition.value}
|
||||||
onChangeComplete={(color) => onChange(param, 'value', color.hex, paramType)}
|
onChangeComplete={handleColorChange}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue