Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alpha not updating #655

Open
tjvg91 opened this issue Nov 21, 2019 · 6 comments
Open

Alpha not updating #655

tjvg91 opened this issue Nov 21, 2019 · 6 comments

Comments

@tjvg91
Copy link

tjvg91 commented Nov 21, 2019

when I change the color property, or change it by clicking the palette, the rgb values change, but not alpha.

@superadminfabian
Copy link

Same issue for me. HandleChangeComplete returns the object with correct alpha, but the alpha in the SketchPicker keeps going back to 100 after clicking an alpha or entering via keyboard.

@stefanfuchs
Copy link

Same problem here.

@stefanfuchs
Copy link

This seems to be the issue: #416
The hex values do not have alpha yet.

I managed to solve the problem by using the rgba value when the alpha isn't 1.

const handleColorChange = (color: ColorResult) => {
    let colorStr = color.hex
    if(color.rgb.a !== 1){
      colorStr = `rgba(${color.rgb.r}, ${color.rgb.g}, ${color.rgb.b}, ${color.rgb.a})`
    }
    // do something with colorStr...
}

@GugaGongadze
Copy link

GugaGongadze commented Jan 10, 2020

Here is the solution for 8-digit hex code:

const decimalToHex = (alpha: number) => alpha === 0 ? '00' : Math.round(255 * alpha).toString(16)

const handleColorChange = (color: ColorResult) => {
   const hexCode = `${c.hex}${decimalToHex(c.rgb.a)}` 
}

@casesandberg
Copy link
Owner

Ah, yes, unfortunately this does not support having alphas on pre-defined swatches yet. I will track this in the 3.0.0 milestone to make sure it gets fixed in the new release.

@cmdparkour
Copy link

keyboard

wow, i fixed it by your answer, thanks very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants