Skip to content

Commit

Permalink
[Playground] EuiKeyPad (#3847)
Browse files Browse the repository at this point in the history
  • Loading branch information
anishagg17 authored and nyurik committed Aug 18, 2020
1 parent 4470046 commit e4d9182
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src-docs/src/views/key_pad_menu/key_pad_menu_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
EuiKeyPadMenuItem,
EuiCallOut,
} from '../../../../src/components';
import { keyPadMenuItemConfig } from './playground';

import KeyPadMenu from './key_pad_menu';
const keyPadMenuSource = require('!!raw-loader!./key_pad_menu');
Expand Down Expand Up @@ -141,4 +142,5 @@ export const KeyPadMenuExample = {
demo: <KeyPadBeta />,
},
],
playground: keyPadMenuItemConfig,
};
78 changes: 78 additions & 0 deletions src-docs/src/views/key_pad_menu/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { PropTypes } from 'react-view';
import {
EuiKeyPadMenuItem,
EuiIcon,
EuiBetaBadge,
} from '../../../../src/components/';
import {
propUtilityForPlayground,
iconValidator,
} from '../../services/playground';
import * as t from '@babel/types';

export const keyPadMenuItemConfig = () => {
const docgenInfo = Array.isArray(EuiKeyPadMenuItem.__docgenInfo)
? EuiKeyPadMenuItem.__docgenInfo[0]
: EuiKeyPadMenuItem.__docgenInfo;
const propsToUse = propUtilityForPlayground(docgenInfo.props);

propsToUse.onClick = {
...propsToUse.onClick,
type: PropTypes.Custom,
value: undefined,
custom: {
...propsToUse.onClick.custom,
use: 'switch',
label: 'Simulate',
},
};
propsToUse.label = {
...propsToUse.label,
type: PropTypes.String,
value: 'Label',
};

propsToUse.betaBadgeTooltipContent = {
...propsToUse.betaBadgeTooltipContent,
type: PropTypes.String,
};

propsToUse.betaBadgeIconType = iconValidator(propsToUse.betaBadgeIconType);

propsToUse.children = {
...propsToUse.children,
type: PropTypes.ReactNode,
value: '<EuiIcon type="dashboardApp" size="l" />',
hidden: false,
};

return {
config: {
componentName: 'EuiKeyPadMenuItem',
props: propsToUse,
scope: {
EuiKeyPadMenuItem,
EuiIcon,
EuiBetaBadge,
},
imports: {
'@elastic/eui': {
named: ['EuiKeyPadMenuItem', 'EuiIcon', 'EuiBetaBadge'],
},
},
customProps: {
onClick: {
generate: val => {
if (!val) return null;
const obj = t.arrowFunctionExpression(
[],
t.blockStatement([]),
false
);
return obj;
},
},
},
},
};
};

0 comments on commit e4d9182

Please sign in to comment.