Skip to content

Commit

Permalink
[components] Fix color picker usability (#6512)
Browse files Browse the repository at this point in the history
  • Loading branch information
sneridagh authored Dec 5, 2024
1 parent 0c352db commit d33d339
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/components/news/6512.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix color picker usability. @sneridagh
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,22 @@ const meta = {
tags: ['autodocs'],
} satisfies Meta<typeof ColorPicker>;

const ColorPickerStory = (args: any) => {
const [color, setColor] = React.useState(args.defaultValue);

return (
<>
<ColorPicker {...args} value={color} onChange={setColor} />
The color is: {color.toString('hex')}
</>
);
};

export default meta;
type Story = StoryObj<typeof meta>;

export const Default: Story = {
render: (args: any) => <ColorPicker {...args} />,
render: ColorPickerStory,
};

Default.args = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,14 @@ export function ColorPicker({ label, children, ...props }: ColorPickerProps) {
yChannel="brightness"
/>
<ColorSlider colorSpace="hsb" channel="hue" />
<ColorField label="Hex" />
<ColorField
label="Hex"
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.currentTarget.blur();
}
}}
/>
</>
)}
</Dialog>
Expand Down

0 comments on commit d33d339

Please sign in to comment.