File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ export type ColorBlockProps = {
66 prefixCls ?: string ;
77 className ?: string ;
88 style ?: React . CSSProperties ;
9+ /** Internal usage. Only used in antd ColorPicker semantic structure only */
10+ innerClassName ?: string ;
11+ /** Internal usage. Only used in antd ColorPicker semantic structure only */
12+ innerStyle ?: React . CSSProperties ;
913 onClick ?: React . MouseEventHandler < HTMLDivElement > ;
1014} ;
1115
@@ -14,6 +18,8 @@ const ColorBlock: React.FC<ColorBlockProps> = ({
1418 prefixCls,
1519 className,
1620 style,
21+ innerClassName,
22+ innerStyle,
1723 onClick,
1824} ) => {
1925 const colorBlockCls = `${ prefixCls } -color-block` ;
@@ -23,7 +29,10 @@ const ColorBlock: React.FC<ColorBlockProps> = ({
2329 style = { style }
2430 onClick = { onClick }
2531 >
26- < div className = { `${ colorBlockCls } -inner` } style = { { background : color } } />
32+ < div
33+ className = { clsx ( `${ colorBlockCls } -inner` , innerClassName ) }
34+ style = { { background : color , ...innerStyle } }
35+ />
2736 </ div >
2837 ) ;
2938} ;
Original file line number Diff line number Diff line change 22import { fireEvent , render } from '@testing-library/react' ;
33import React from 'react' ;
44import { expect } from 'vitest' ;
5- import ColorPicker , { type BaseSliderProps } from '../src' ;
5+ import ColorPicker , { ColorBlock , type BaseSliderProps } from '../src' ;
66import { defaultColor } from '../src/util' ;
77
88describe ( 'ColorPicker.Components' , ( ) => {
@@ -56,4 +56,19 @@ describe('ColorPicker.Components', () => {
5656 fireEvent . click ( alphaEle ) ;
5757 expect ( alphaEle . textContent ) . toBe ( '0/100/33' ) ;
5858 } ) ;
59+
60+ it ( 'ColorBlock support innerClassName and innerStyle' , ( ) => {
61+ const { container } = render (
62+ < ColorBlock
63+ prefixCls = "test"
64+ color = "red"
65+ innerClassName = "my-inner-class"
66+ innerStyle = { { color : '#903' } }
67+ /> ,
68+ ) ;
69+
70+ const innerDiv = container . querySelector ( '.test-color-block-inner' ) ;
71+ expect ( innerDiv ) . toHaveClass ( 'my-inner-class' ) ;
72+ expect ( innerDiv ) . toHaveStyle ( { color : '#903' } ) ;
73+ } ) ;
5974} ) ;
Original file line number Diff line number Diff line change 88 "skipLibCheck" : true ,
99 "esModuleInterop" : true ,
1010 "module" : " ESNext" ,
11- "types" : [" vitest/globals" ],
11+ "types" : [" vitest/globals" , " @testing-library/jest-dom " ],
1212 "paths" : {
1313 "@@/*" : [" .dumi/tmp/*" ],
1414 "@rc-component/color-picker" : [" src/index.tsx" ]
You can’t perform that action at this time.
0 commit comments