Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Playground] EuiAccordion #3886

Merged
merged 3 commits into from
Aug 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src-docs/src/services/playground/dummyFunction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as t from '@babel/types';

export const dummyFunction = {
generate: val => {
if (!val) return null;
const obj = t.arrowFunctionExpression([], t.blockStatement([]), false);
return obj;
},
};
1 change: 1 addition & 0 deletions src-docs/src/services/playground/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export { default as propUtilityForPlayground } from './props';
export { mapOptions } from './mapOptions';
export { iconValidator } from './iconValidator';
export { createOptionalEnum } from './createOptionalEnum';
export { dummyFunction } from './dummyFunction';
3 changes: 3 additions & 0 deletions src-docs/src/views/accordion/accordion_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {
EuiSpacer,
} from '../../../../src/components';

import { accordionConfig } from './playground';

import Accordion from './accordion';
const accordionSource = require('!!raw-loader!./accordion');
const accordionHtml = renderToHtml(Accordion);
Expand Down Expand Up @@ -354,4 +356,5 @@ export const AccordionExample = {
demo: <AccordionForceState />,
},
],
playground: accordionConfig,
};
61 changes: 61 additions & 0 deletions src-docs/src/views/accordion/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { PropTypes } from 'react-view';
import { EuiAccordion, EuiText } from '../../../../src/components/';
import {
propUtilityForPlayground,
createOptionalEnum,
dummyFunction,
} from '../../services/playground';

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

propsToUse.buttonContent = {
...propsToUse.buttonContent,
value: 'Click me to toggle',
type: PropTypes.String,
};

propsToUse.children = {
value: `<EuiText>
<p>
Any content inside of <strong>EuiAccordion</strong> will appear here.
</p>
</EuiText>`,
type: PropTypes.ReactNode,
hidden: false,
};

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

propsToUse.forceState = createOptionalEnum(propsToUse.forceState);

return {
config: {
componentName: 'EuiAccordion',
props: propsToUse,
scope: {
EuiAccordion,
EuiText,
},
imports: {
'@elastic/eui': {
named: ['EuiAccordion', 'EuiText'],
},
},
customProps: {
onToggle: dummyFunction,
},
},
};
};
14 changes: 2 additions & 12 deletions src-docs/src/views/badge/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
import {
propUtilityForPlayground,
iconValidator,
dummyFunction,
} from '../../services/playground';
import * as t from '@babel/types';

export const badgeConfig = () => {
const docgenInfo = Array.isArray(EuiBadge.__docgenInfo)
Expand Down Expand Up @@ -88,17 +88,7 @@ export const badgeConfig = () => {
},
},
customProps: {
onClick: {
generate: val => {
if (!val) return null;
const obj = t.arrowFunctionExpression(
[],
t.blockStatement([]),
false
);
return obj;
},
},
onClick: dummyFunction,
},
},
};
Expand Down
18 changes: 5 additions & 13 deletions src-docs/src/views/card/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PropTypes } from 'react-view';
import { EuiCard } from '../../../../src/components/';
import { propUtilityForPlayground } from '../../services/playground';
import * as t from '@babel/types';
import {
propUtilityForPlayground,
dummyFunction,
} from '../../services/playground';

export default () => {
const docgenInfo = Array.isArray(EuiCard.__docgenInfo)
Expand Down Expand Up @@ -50,17 +52,7 @@ export default () => {
},
},
customProps: {
onClick: {
generate: val => {
if (!val) return null;
const obj = t.arrowFunctionExpression(
[],
t.blockStatement([]),
false
);
return obj;
},
},
onClick: dummyFunction,
},
},
};
Expand Down
14 changes: 2 additions & 12 deletions src-docs/src/views/toast/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import {
propUtilityForPlayground,
iconValidator,
createOptionalEnum,
dummyFunction,
} from '../../services/playground';
import * as t from '@babel/types';

export default () => {
const docgenInfo = Array.isArray(EuiToast.__docgenInfo)
Expand Down Expand Up @@ -47,17 +47,7 @@ export default () => {
},
},
customProps: {
onClose: {
generate: val => {
if (!val) return null;
const obj = t.arrowFunctionExpression(
[],
t.blockStatement([]),
false
);
return obj;
},
},
onClose: dummyFunction,
},
},
};
Expand Down
18 changes: 5 additions & 13 deletions src-docs/src/views/tool_tip/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { PropTypes } from 'react-view';
import { EuiToolTip } from '../../../../src/components/';
import { propUtilityForPlayground } from '../../services/playground';
import * as t from '@babel/types';
import {
propUtilityForPlayground,
dummyFunction,
} from '../../services/playground';

export default () => {
const docgenInfo = Array.isArray(EuiToolTip.__docgenInfo)
Expand Down Expand Up @@ -52,17 +54,7 @@ export default () => {
},
},
customProps: {
onMouseOut: {
generate: val => {
if (!val) return null;
const obj = t.arrowFunctionExpression(
[],
t.blockStatement([]),
false
);
return obj;
},
},
onMouseOut: dummyFunction,
},
},
};
Expand Down