a11y-theme-builder
a11y-theme-builder copied to clipboard
Fixed Hex Value Visibility and Dynamic Color Name Display in Color Palette Component
Changes I Made to Fix Hex Value Visibility and Dynamic Color Name Display Issues :
-
Installed
color-namer
Package:- I installed the
color-namer
package to convert color hex codes to color names.
- I installed the
-
Updated Imports:
- I imported the
color-namer
package in theColorPaletteAtom
component.
- I imported the
-
Utility Functions:
- I created a utility function to determine the text color based on the brightness of the background color.
- I created a utility function to get the color name from a hex value using the
color-namer
package.
-
State Management:
- I added state variables to manage the selected color and its complementary text color.
- I updated the state variable for the color name to display the name of the selected color.
-
UI Adjustments:
- I removed the background color of the hex value
TextField
to ensure visibility. - I added a separate block to visually display the selected color instead of showing the color in the hex value field.
- I ensured that the "Color Name" field displays the color name dynamically when a color is selected using the color picker.
- I removed the background color of the hex value
-
Event Handlers:
- I updated the
reflectColorPickerChangeInUI
function to use the new utility function to set the color name. - I modified the event handlers to handle changes and blur events appropriately for the color name and hex value fields.
- I updated the
Now it looks like this :