@@ -15,13 +15,23 @@ const CORLER_HEX = ['#D9E3F0', '#F47373', '#697689', '#37D67A', '#2CCCE4', '#555
15
15
16
16
export interface BlockProps extends Omit < React . HTMLAttributes < HTMLDivElement > , 'onChange' | 'color' > {
17
17
prefixCls ?: string ;
18
+ showTriangle ?: boolean ;
18
19
color ?: string | HsvaColor ;
19
20
colors ?: string [ ] ;
20
21
onChange ?: ( color : ColorResult ) => void ;
21
22
}
22
23
23
24
const Block = React . forwardRef < HTMLDivElement , BlockProps > ( ( props , ref ) => {
24
- const { prefixCls = 'w-color-block' , className, style, color, colors = CORLER_HEX , onChange, ...other } = props ;
25
+ const {
26
+ prefixCls = 'w-color-block' ,
27
+ className,
28
+ style,
29
+ color,
30
+ colors = CORLER_HEX ,
31
+ showTriangle = true ,
32
+ onChange,
33
+ ...other
34
+ } = props ;
25
35
const hsva = ( typeof color === 'string' && validHex ( color ) ? hexToHsva ( color ) : color ) as HsvaColor ;
26
36
const hex = color ? hsvaToHex ( hsva ) : '' ;
27
37
const handleChange = ( hsv : HsvaColor ) => {
@@ -44,19 +54,21 @@ const Block = React.forwardRef<HTMLDivElement, BlockProps>((props, ref) => {
44
54
} as CSSProperties ;
45
55
return (
46
56
< div ref = { ref } className = { [ prefixCls , className ] . filter ( Boolean ) . join ( ' ' ) } style = { stylePointer } { ...other } >
47
- < div
48
- style = { {
49
- width : 0 ,
50
- height : 0 ,
51
- borderStyle : 'solid' ,
52
- borderWidth : '0 10px 10px' ,
53
- borderColor : `transparent transparent ${ hex } ` ,
54
- position : 'absolute' ,
55
- top : - 10 ,
56
- left : '50%' ,
57
- marginLeft : - 10 ,
58
- } }
59
- />
57
+ { showTriangle && (
58
+ < div
59
+ style = { {
60
+ width : 0 ,
61
+ height : 0 ,
62
+ borderStyle : 'solid' ,
63
+ borderWidth : '0 10px 10px' ,
64
+ borderColor : `transparent transparent ${ hex } ` ,
65
+ position : 'absolute' ,
66
+ top : - 10 ,
67
+ left : '50%' ,
68
+ marginLeft : - 10 ,
69
+ } }
70
+ />
71
+ ) }
60
72
< div
61
73
title = { hex }
62
74
style = { {
0 commit comments