Build a Customizable Hex Color Picker Component
At Lenskart, precise color management is crucial for our digital product experiences, from customizing frame colors in our virtual try-on to defining thematic elements across our applications. We need a robust, reusable ColorPicker component that allows designers and product managers to easily select and input HEX color codes. This component will be integrated into various configuration interfaces, ensuring brand consistency and enabling dynamic visual adjustments.
Your primary task is to develop a ColorPicker React component with the following capabilities:
#RRGGBB). This input should update the displayed color.defaultColor as a prop for initial state and onColorChange as a callback prop to inform the parent component of color changes.backgroundColor of the selected color, along with its full HEX code (e.g., #FF0000).ColorPicker component renders correctly with a defaultColor if provided, or a fallback if not.# prefix) into the input field updates the main display swatch and HEX code.onColorChange prop is called with the new HEX color whenever the color is changed via palette selection or custom input.Constraints
#RRGGBB or RRGGBB) need to be handled. No RGB, HSL, or other formats.ColorPicker component is structured, its API (props), and its reusability.useState and useEffect for managing component state and side effects.Loading editor...