From 26fce86292343a3fb780fbabddf5b165e760e340 Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Mon, 4 Mar 2024 02:00:44 +0800 Subject: [PATCH] fix(Circle): fix `pointProps` props. #142 --- packages/color-circle/README.md | 33 +++++++++++++++++++++++++++++ packages/color-circle/src/Point.tsx | 2 +- packages/color-circle/src/index.tsx | 21 ++++++++++++++++-- 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/packages/color-circle/README.md b/packages/color-circle/README.md index 137e15a34..82a9e4269 100644 --- a/packages/color-circle/README.md +++ b/packages/color-circle/README.md @@ -36,6 +36,38 @@ export default function Demo() { } ``` +Modify point style + +```jsx mdx:preview +import React, { useState } from 'react'; +import Circle from '@uiw/react-color-circle'; + +export default function Demo() { + const [hex, setHex] = useState('#F44E3B'); + return ( + { + setHex(color.hex); + }} + /> + ); +} +``` + ## Props ```ts @@ -45,6 +77,7 @@ import { SwatchProps } from '@uiw/react-color-swatch'; export interface CircleProps extends Omit { color?: string | HsvaColor; onChange?: (color: ColorResult) => void; + pointProps?: React.HTMLAttributes; } declare const Circle: React.ForwardRefExoticComponent>; export default Circle; diff --git a/packages/color-circle/src/Point.tsx b/packages/color-circle/src/Point.tsx index b5149dfb4..7129a8689 100644 --- a/packages/color-circle/src/Point.tsx +++ b/packages/color-circle/src/Point.tsx @@ -37,7 +37,6 @@ export default function Point({ style, className, title, checked, color, onClick title={title} className={className} style={{ - ...style, display: 'flex', alignItems: 'center', justifyContent: 'center', @@ -51,6 +50,7 @@ export default function Point({ style, className, title, checked, color, onClick transform: 'scale(1)', boxShadow: `${color} 0px 0px ${checked ? 5 : 0}px`, transition: 'transform 100ms ease 0s, box-shadow 100ms ease 0s', + ...style, }} >
diff --git a/packages/color-circle/src/index.tsx b/packages/color-circle/src/index.tsx index ad5635252..4f1517eb7 100644 --- a/packages/color-circle/src/index.tsx +++ b/packages/color-circle/src/index.tsx @@ -10,7 +10,16 @@ export interface CircleProps extends Omit { } const Circle = React.forwardRef((props, ref) => { - const { prefixCls = 'w-color-circle', className, color, colors = [], rectProps = {}, pointProps, onChange, ...other } = props; + const { + prefixCls = 'w-color-circle', + className, + color, + colors = [], + rectProps = {}, + pointProps = {}, + onChange, + ...other + } = props; const hsva = (typeof color === 'string' && validHex(color) ? hexToHsva(color) : color || {}) as HsvaColor; const hex = color ? hsvaToHex(hsva) : ''; const cls = [prefixCls, className].filter(Boolean).join(' '); @@ -22,7 +31,15 @@ const Circle = React.forwardRef((props, ref) => { color={hex} {...other} className={cls} - rectRender={({ ...props }) => } + rectRender={({ ...props }) => ( + + )} onChange={(hsvColor) => { onChange && onChange(handleColor(hsvColor)); }}