From 6d08b4c8431a566dfaba9271965db70e102172be Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Sat, 1 Aug 2020 18:27:20 +0530 Subject: [PATCH 1/3] [Playground] EuiKeyPad --- .../key_pad_menu/key_pad_menu_example.js | 2 + src-docs/src/views/key_pad_menu/playground.js | 79 +++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src-docs/src/views/key_pad_menu/playground.js diff --git a/src-docs/src/views/key_pad_menu/key_pad_menu_example.js b/src-docs/src/views/key_pad_menu/key_pad_menu_example.js index 4f479fff5a1..e2ee7f6b150 100644 --- a/src-docs/src/views/key_pad_menu/key_pad_menu_example.js +++ b/src-docs/src/views/key_pad_menu/key_pad_menu_example.js @@ -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'); @@ -141,4 +142,5 @@ export const KeyPadMenuExample = { demo: , }, ], + playground: keyPadMenuItemConfig, }; diff --git a/src-docs/src/views/key_pad_menu/playground.js b/src-docs/src/views/key_pad_menu/playground.js new file mode 100644 index 00000000000..bc80968f9c4 --- /dev/null +++ b/src-docs/src/views/key_pad_menu/playground.js @@ -0,0 +1,79 @@ +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, + value: 'betaBadge tooltip content', + }; + + propsToUse.betaBadgeIconType = iconValidator(propsToUse.betaBadgeIconType); + + propsToUse.children = { + ...propsToUse.children, + type: PropTypes.ReactNode, + value: '', + 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; + }, + }, + }, + }, + }; +}; From 664ef86a4329b5caefefe8076149b184e40acaf5 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Wed, 5 Aug 2020 02:37:24 +0530 Subject: [PATCH 2/3] Update src-docs/src/views/key_pad_menu/playground.js Co-authored-by: Caroline Horn <549577+cchaos@users.noreply.github.com> --- src-docs/src/views/key_pad_menu/playground.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src-docs/src/views/key_pad_menu/playground.js b/src-docs/src/views/key_pad_menu/playground.js index bc80968f9c4..6fc47a6661e 100644 --- a/src-docs/src/views/key_pad_menu/playground.js +++ b/src-docs/src/views/key_pad_menu/playground.js @@ -29,7 +29,7 @@ export const keyPadMenuItemConfig = () => { propsToUse.label = { ...propsToUse.label, type: PropTypes.String, - value: 'label', + value: 'Label', }; propsToUse.betaBadgeTooltipContent = { From 2d968b34befec762629fbbfe0060a5976565e592 Mon Sep 17 00:00:00 2001 From: Anish Aggarwal Date: Wed, 5 Aug 2020 02:43:05 +0530 Subject: [PATCH 3/3] Update playground.js --- src-docs/src/views/key_pad_menu/playground.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src-docs/src/views/key_pad_menu/playground.js b/src-docs/src/views/key_pad_menu/playground.js index 6fc47a6661e..aa0e8e93c55 100644 --- a/src-docs/src/views/key_pad_menu/playground.js +++ b/src-docs/src/views/key_pad_menu/playground.js @@ -35,7 +35,6 @@ export const keyPadMenuItemConfig = () => { propsToUse.betaBadgeTooltipContent = { ...propsToUse.betaBadgeTooltipContent, type: PropTypes.String, - value: 'betaBadge tooltip content', }; propsToUse.betaBadgeIconType = iconValidator(propsToUse.betaBadgeIconType);