From dd29c6fa280ab0818906fb3927547a9c79f432c5 Mon Sep 17 00:00:00 2001 From: Innders <49156310+Innders@users.noreply.github.com> Date: Tue, 31 Dec 2024 14:30:30 +0000 Subject: [PATCH] fix: InputColor improvements --- src/Dropdowns/SortingDropdown/SortCard.tsx | 9 ++++++++- src/Inputs/InputColor/ColorPickerPreview.tsx | 9 ++++++--- src/Inputs/InputColor/InputColor.tsx | 12 +++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/Dropdowns/SortingDropdown/SortCard.tsx b/src/Dropdowns/SortingDropdown/SortCard.tsx index 1691d5f..6bd676c 100644 --- a/src/Dropdowns/SortingDropdown/SortCard.tsx +++ b/src/Dropdowns/SortingDropdown/SortCard.tsx @@ -2,6 +2,7 @@ import { forwardRef } from 'react' import { SortCardType } from './SortingDropdown' import { Icon } from '../../Icon' import * as Styled from './SortCard.styled' +import clsx from 'clsx' interface SortCardProps extends SortCardType, Omit, 'id'> { onRemove: () => void @@ -12,7 +13,13 @@ interface SortCardProps extends SortCardType, Omit( ({ id, label, sortOrder, onRemove, onSortBy, disabled, ...props }, ref) => { return ( - + { diff --git a/src/Inputs/InputColor/ColorPickerPreview.tsx b/src/Inputs/InputColor/ColorPickerPreview.tsx index bea9e7b..a9260a5 100644 --- a/src/Inputs/InputColor/ColorPickerPreview.tsx +++ b/src/Inputs/InputColor/ColorPickerPreview.tsx @@ -1,8 +1,9 @@ +import clsx from 'clsx' import { ChangeEvent, FC, FocusEvent, forwardRef } from 'react' import styled, { css } from 'styled-components' // types -export interface ColorPickerPreviewProps { +export interface ColorPickerPreviewProps extends React.HTMLAttributes { onClick?: () => void onChange?: (e: ChangeEvent) => void backgroundColor?: string @@ -68,9 +69,9 @@ const ColorButton = styled.button` ` const ColorPickerPreview = forwardRef( - ({ onClick, onChange, backgroundColor, value, onBlur }, ref) => { + ({ onClick, onChange, backgroundColor, value, onBlur, ...props }, ref) => { return ( - + ( onChange={onChange && onChange} value={value} onBlur={onBlur} + className="color-picker-input" /> ( disabled={!onClick} tabIndex={!onClick ? -1 : 0} onClick={onClick} + className="color-picker-button" /> ) diff --git a/src/Inputs/InputColor/InputColor.tsx b/src/Inputs/InputColor/InputColor.tsx index 58815ba..0aab576 100644 --- a/src/Inputs/InputColor/InputColor.tsx +++ b/src/Inputs/InputColor/InputColor.tsx @@ -57,18 +57,19 @@ const formatsConfig = { }, } -export interface InputColorProps { +export interface InputColorProps extends Omit, 'onChange'> { value: string | number[] onChange: (event: { target: { value: string | number[] } }) => void alpha?: boolean format?: 'hex' | 'float' | 'uint8' | 'uint16' - className?: string - style?: HTMLAttributes['style'] + pt?: { + preview?: HTMLAttributes + } } // REACT FUNCTIONAL COMPONENT export const InputColor = forwardRef( - ({ value, onChange, alpha, format = 'hex', className, style }, ref) => { + ({ value, onChange, alpha, format = 'hex', pt = { preview: {} }, ...props }, ref) => { const isHex = format === 'hex' let initValue: string | number[] @@ -226,8 +227,9 @@ export const InputColor = forwardRef( const useDialog = alpha || ['uint16', 'float'].includes(format) return ( -
+