Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: ColorPicker implement showText API #42865

Merged
merged 13 commits into from Jun 19, 2023
16 changes: 14 additions & 2 deletions components/color-picker/ColorPicker.tsx
Expand Up @@ -41,6 +41,8 @@ export type ColorPickerProps = Omit<
allowClear?: boolean;
presets?: PresetsItem[];
arrow?: boolean | { pointAtCenter: boolean };
showText?: boolean;
textRender?: (color: Color) => React.ReactNode;
li-jia-nan marked this conversation as resolved.
Show resolved Hide resolved
styles?: { popup?: CSSProperties };
rootClassName?: string;
onOpenChange?: (open: boolean) => void;
Expand All @@ -66,6 +68,8 @@ const ColorPicker: CompoundedComponent = (props) => {
disabled,
placement = 'bottomLeft',
arrow = true,
textRender,
showText,
style,
className,
rootClassName,
Expand All @@ -91,6 +95,11 @@ const ColorPicker: CompoundedComponent = (props) => {
postState: (openData) => !disabled && openData,
onChange: onOpenChange,
});
const [formatValue, setFormatValue] = useMergedState(format, {
value: format,
onChange: onFormatChange,
});

const [colorCleared, setColorCleared] = useState(false);

const prefixCls = getPrefixCls('color-picker', customizePrefixCls);
Expand Down Expand Up @@ -151,8 +160,8 @@ const ColorPicker: CompoundedComponent = (props) => {
colorCleared,
disabled,
presets,
format,
onFormatChange,
format: formatValue,
onFormatChange: setFormatValue,
};

return wrapSSR(
Expand Down Expand Up @@ -183,6 +192,9 @@ const ColorPicker: CompoundedComponent = (props) => {
prefixCls={prefixCls}
disabled={disabled}
colorCleared={colorCleared}
textRender={textRender}
showText={showText}
format={formatValue}
/>
)}
</Popover>,
Expand Down