Files
spacedrive/interface/components/ColorPicker.tsx
nikec afb2cea12d [Desktop] Fix input right buttons (#651)
* update color picker

* fix position and ref

* style hex input

* update input field

* add Icon type option

* Update input

* change right padding on lg size

* update other inputs

* update color picker input

---------

Co-authored-by: Brendan Allan <brendonovich@outlook.com>
2023-03-30 03:08:04 +00:00

33 lines
898 B
TypeScript

import clsx from 'clsx';
import { HexColorInput, HexColorPicker } from 'react-colorful';
import { FieldValues, UseControllerProps, useController } from 'react-hook-form';
import { Popover, inputStyles } from '@sd/ui';
interface Props<T extends FieldValues> extends UseControllerProps<T> {
className?: string;
}
export default <T extends FieldValues>({ className, ...props }: Props<T>) => {
const { field } = useController({ name: props.name });
return (
<Popover
trigger={
<div
className={clsx('h-4 w-4 rounded-full shadow', className)}
style={{ backgroundColor: field.value }}
/>
}
className="p-3"
sideOffset={5}
>
<HexColorPicker color={field.value} onChange={field.onChange} />
<HexColorInput
color={field.value}
onChange={field.onChange}
className={inputStyles({ size: 'md', className: '!mt-5 bg-app px-3' })}
/>
</Popover>
);
};