颜色选择逻辑修复
This commit is contained in:
parent
16edc47a1f
commit
bd554b2c37
|
@ -6,8 +6,9 @@
|
|||
- `format` 请选择 `hex`、`hls`、`rgb`或者`rgba`。默认为 `hex`。
|
||||
- `presetColors` 选择器底部的默认颜色
|
||||
- 默认为`['#D0021B', '#F5A623', '#F8E71C', '#8B572A', '#7ED321', '#417505', '#BD10E0', '#9013FE', '#4A90E2', '#50E3C2', '#B8E986', '#000000', '#4A4A4A', '#9B9B9B', '#FFFFFF']`,数组内为空则不显示默认颜色
|
||||
- `allowCustomColor` 自定义颜色选择,默认为`false`,使用 `presetColors` 自定义颜色
|
||||
- `allowCustomColor` 是否允许自定义颜色,默认为`true`,为`false`时只能选择颜色,使用 `presetColors` 设定颜色选择范围
|
||||
- `clearable` 是否显示清除按钮。
|
||||
- `resetValue` 默认为 `""`, 删除后设置此配置项给定的值。
|
||||
|
||||
```schema:height="400" scope="form-item"
|
||||
{
|
||||
|
@ -20,6 +21,6 @@
|
|||
"type": "color",
|
||||
"name": "customColor",
|
||||
"label": "自定义颜色",
|
||||
"allowCustomColor": true
|
||||
"allowCustomColor": false
|
||||
}
|
||||
```
|
||||
|
|
|
@ -46,7 +46,7 @@ export class ColorControl extends React.PureComponent<
|
|||
format: 'hex',
|
||||
clearable: true,
|
||||
placeholder: '请选择颜色',
|
||||
allowCustomColor: false
|
||||
allowCustomColor: true
|
||||
// closeOnSelect: true
|
||||
};
|
||||
state = {
|
||||
|
@ -254,19 +254,19 @@ export class ColorControl extends React.PureComponent<
|
|||
overlay
|
||||
>
|
||||
{allowCustomColor ? (
|
||||
<SketchPicker
|
||||
disableAlpha={!!~['rgb', 'hex'].indexOf(format as string)}
|
||||
color={value}
|
||||
presetColors={presetColors}
|
||||
onChangeComplete={this.handleChange}
|
||||
/>
|
||||
) : (
|
||||
<GithubPicker
|
||||
color={value}
|
||||
colors={presetColors}
|
||||
onChangeComplete={this.handleChange}
|
||||
/>
|
||||
) : (
|
||||
<SketchPicker
|
||||
disableAlpha={!!~['rgb', 'hex'].indexOf(format as string)}
|
||||
color={value}
|
||||
presetColors={presetColors}
|
||||
onChangeComplete={this.handleChange}
|
||||
/>
|
||||
)
|
||||
}
|
||||
)}
|
||||
</PopOver>
|
||||
</Overlay>
|
||||
) : null}
|
||||
|
|
Loading…
Reference in New Issue