Skip to content

Commit

Permalink
[Playground] EuiColorPicker (#3955)
Browse files Browse the repository at this point in the history
* [Playground] EuiColorPicker

* fixed default value selection and error message issue
  • Loading branch information
anishagg17 authored Aug 25, 2020
1 parent 399883b commit e1072f9
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src-docs/src/services/playground/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,7 @@ const getProp = prop => {
newProp.type = PropTypes.Enum;
newProp.required = prop.required;
if (prop.defaultValue) {
newProp.defaultValue = prop.defaultValue.value.substring(
1,
prop.defaultValue.value.length - 1
);
newProp.defaultValue = prop.defaultValue.value;
}
newProp.value = undefined;
newProp.options = {};
Expand Down
3 changes: 3 additions & 0 deletions src-docs/src/views/color_picker/color_picker_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import {
EuiColorPalettePickerPaletteGradientProps,
} from '!!prop-loader!../../../../src/components/color_picker/color_palette_picker/color_palette_picker';

import playgrounds from './playground';

import ColorPicker from './color_picker';
const colorPickerSource = require('!!raw-loader!./color_picker');
const colorPickerHtml = renderToHtml(ColorPicker);
Expand Down Expand Up @@ -648,4 +650,5 @@ export const ColorPickerExample = {
demo: <KitchenSink />,
},
],
playground: playgrounds,
};
72 changes: 72 additions & 0 deletions src-docs/src/views/color_picker/playground.js
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];

0 comments on commit e1072f9

Please sign in to comment.