@@ -21,6 +21,7 @@ interface ColorSelectProps {
21
21
dispatch ?: ( value : any ) => void ;
22
22
changeColor ?: ( value : any ) => void ;
23
23
presetColors ?: string [ ] ;
24
+ allowGradient ?: boolean ;
24
25
}
25
26
26
27
export const ColorSelect = ( props : ColorSelectProps ) => {
@@ -31,9 +32,11 @@ export const ColorSelect = (props: ColorSelectProps) => {
31
32
32
33
const presetColors = useMemo ( ( ) => {
33
34
let colors = props . presetColors || [ ] ;
34
- colors = colors . concat ( gradientColors . slice ( 0 , 16 - colors . length ) ) ;
35
+ if ( props . allowGradient ) {
36
+ colors = colors . concat ( gradientColors . slice ( 0 , 16 - colors . length ) ) ;
37
+ }
35
38
return colors ;
36
- } , [ props . presetColors , selectedColor ] ) ;
39
+ } , [ props . presetColors , selectedColor , props . allowGradient ] ) ;
37
40
38
41
const throttleChange = useCallback (
39
42
throttle ( ( rgbaColor : string ) => {
@@ -70,6 +73,7 @@ export const ColorSelect = (props: ColorSelectProps) => {
70
73
width = { 250 }
71
74
height = { 160 }
72
75
presets = { presetColors }
76
+ $allowGradient = { props . allowGradient }
73
77
/>
74
78
</ PopoverContainer >
75
79
}
@@ -191,11 +195,14 @@ const ColorBlock = styled.div<{ $color: string }>`
191
195
overflow: hidden;
192
196
` ;
193
197
194
- const StyledColorPicker = styled ( ColorPicker ) `
198
+ const StyledColorPicker = styled ( ColorPicker ) < { $allowGradient ?: boolean } > `
199
+ #rbgcp-wrapper > div:nth-child(2) > div:first-child > div:first-child {
200
+ ${ props => ! props . $allowGradient && `visibility: hidden` } ;
201
+ }
195
202
#rbgcp-wrapper > div:last-child > div:last-child {
196
203
justify-content: flex-start !important;
197
204
gap: 3px;
198
-
205
+
199
206
> div {
200
207
border: 1px solid lightgray;
201
208
}
0 commit comments