Hello team,
working on ImageSettings components I've been experiencing some issues and finally seems they come from PanelColorSettings component. I'll explain here:
Problem
ImageSettings components works, as other does, with an object that is stringified and saved as string on props. Everything runs perfect, but each time I changed any option related with color, all the properties of the object returned to the last saved ones. For example, saved the block with the image with alignment 'left', changed to 'right', and after changed the background color: the alignment returns to 'left'.
What happens?
Seems like the scope of the PanelColorSettings is not catching the value send. Checking the object stringified, it gets to the component once and is not update, so it's returning the object always on its first schema.
The reason? I don't know. If you figure out why, please, let me know: I'll sleep better ๐
Solution
I create a cleaner solution for having a color component. I called it ColorControl, and also gives the opportunity to add an alpha value to the color.
Some of the advantages are:
- Returns a RGBA value, so it can have Alpha value (opacity)
- Can have GradientPicker component and activate it easily
- Would be cleaner on the code
Some disadvantages are:
- It would need to be implemented in all the existent components
- Needs new styling CSS, may can be reused from the old component.
You'll find more on wiki
You'll find the prototype on my branch. I would appreciate your opinion, suggestions or comments in order to keep working on it.
Thanks for your time ๐