Skip to content

Commit b76b9d0

Browse files
authored
feat(compact): Pass addonBefore and addonAfter props to react-compact (#183)
* pass addonBefore and addonAfter props to react-compact * react-color-compact: add className for editable input
1 parent 26f41e5 commit b76b9d0

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

packages/color-compact/src/index.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export interface CompactProps<T> extends Omit<React.HTMLAttributes<HTMLDivElemen
1919
onChange?: (color: ColorResult, evn?: T) => void;
2020
rectRender?: (props: SwatchRectRenderProps) => JSX.Element | undefined;
2121
rectProps?: SwatchProps['rectProps'];
22+
addonBefore?: React.ReactNode;
23+
addonAfter?: React.ReactNode;
2224
}
2325

2426
const COLORS = [
@@ -84,6 +86,8 @@ const Compact = React.forwardRef<HTMLDivElement, CompactProps<React.MouseEvent<H
8486
colors = COLORS,
8587
rectProps,
8688
rectRender,
89+
addonBefore,
90+
addonAfter,
8791
...other
8892
} = props;
8993
const hsva = (typeof color === 'string' && validHex(color) ? hexToHsva(color) : color) as HsvaColor;
@@ -128,8 +132,13 @@ const Compact = React.forwardRef<HTMLDivElement, CompactProps<React.MouseEvent<H
128132
},
129133
}}
130134
onChange={(hsvColor) => handleChangeCallback(hsvColor)}
135+
addonBefore={addonBefore}
136+
addonAfter={addonAfter}
131137
/>
132-
<div style={{ display: 'flex', margin: '0 4px 3px 0' }}>
138+
<div
139+
className={[`${prefixCls}-input-wrapper`, className || ''].filter(Boolean).join(' ')}
140+
style={{ display: 'flex', margin: '0 4px 3px 0' }}
141+
>
133142
<EditableInput
134143
onChange={(evn, val) => handleHex(val, evn)}
135144
labelStyle={{ paddingRight: 5, marginTop: -1 }}

0 commit comments

Comments
 (0)