-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* [Playground] EuiColorPicker * fixed default value selection and error message issue
- Loading branch information
1 parent
399883b
commit e1072f9
Showing
3 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import { | ||
propUtilityForPlayground, | ||
dummyFunction, | ||
simulateFunction, | ||
createOptionalEnum, | ||
} from '../../services/playground'; | ||
import { EuiColorPicker } from '../../../../src/components/'; | ||
import { PropTypes } from 'react-view'; | ||
|
||
const colorPickerConfig = () => { | ||
const docgenInfo = Array.isArray(EuiColorPicker.__docgenInfo) | ||
? EuiColorPicker.__docgenInfo[0] | ||
: EuiColorPicker.__docgenInfo; | ||
const propsToUse = propUtilityForPlayground(docgenInfo.props); | ||
|
||
propsToUse.append = { | ||
...propsToUse.append, | ||
type: PropTypes.String, | ||
}; | ||
propsToUse.prepend = { | ||
...propsToUse.prepend, | ||
type: PropTypes.String, | ||
}; | ||
|
||
propsToUse.color = { | ||
...propsToUse.color, | ||
stateful: false, | ||
type: PropTypes.String, | ||
value: '#D36086', | ||
}; | ||
|
||
propsToUse.secondaryInputDisplay = { | ||
...propsToUse.secondaryInputDisplay, | ||
custom: { | ||
...propsToUse.secondaryInputDisplay.custom, | ||
checkDep: (val, state) => { | ||
if (state.mode.value === 'secondaryInput' && !val) { | ||
return 'When mode is set to secondaryInput, you must also provide secondaryInputDisplay'; | ||
} | ||
return undefined; | ||
}, | ||
}, | ||
}; | ||
|
||
propsToUse.format = createOptionalEnum(propsToUse.format); | ||
|
||
propsToUse.onChange = simulateFunction(propsToUse.onChange); | ||
propsToUse.onBlur = simulateFunction(propsToUse.onBlur); | ||
propsToUse.onFocus = simulateFunction(propsToUse.onFocus); | ||
|
||
return { | ||
config: { | ||
componentName: 'EuiColorPicker', | ||
props: propsToUse, | ||
scope: { | ||
EuiColorPicker, | ||
}, | ||
imports: { | ||
'@elastic/eui': { | ||
named: ['EuiColorPicker'], | ||
}, | ||
}, | ||
customProps: { | ||
onChange: dummyFunction, | ||
onBlur: dummyFunction, | ||
onFocus: dummyFunction, | ||
}, | ||
}, | ||
}; | ||
}; | ||
|
||
export default [colorPickerConfig]; |