Skip to content

Commit

Permalink
[Playground] EuiExpression (#3917)
Browse files Browse the repository at this point in the history
Co-authored-by: Greg Thompson <[email protected]>
  • Loading branch information
anishagg17 and thompsongl authored Aug 18, 2020
1 parent 635ceb1 commit 0bf5673
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src-docs/src/views/expression/expression_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { EuiCode } from '../../../../src/components';

import { EuiExpression } from '../../../../src/components/expression';

import { expressionConfig } from './playground';

import Expression from './expression';
const expressionSource = require('!!raw-loader!./expression');
const expressionHtml = renderToHtml(Expression);
Expand Down Expand Up @@ -226,4 +228,5 @@ export const ExpressionExample = {
demo: <Truncate />,
},
],
playground: expressionConfig,
};
59 changes: 59 additions & 0 deletions src-docs/src/views/expression/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { PropTypes } from 'react-view';
import { EuiExpression } from '../../../../src/components/';
import {
propUtilityForPlayground,
dummyFunction,
} from '../../services/playground';

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

propsToUse.value = {
...propsToUse.value,
type: PropTypes.String,
value: '100',
};

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

propsToUse.description = {
...propsToUse.description,
type: PropTypes.String,
value: 'Is above',
};

propsToUse.descriptionWidth = {
...propsToUse.descriptionWidth,
type: PropTypes.Number,
};

return {
config: {
componentName: 'EuiExpression',
props: propsToUse,
scope: {
EuiExpression,
},
imports: {
'@elastic/eui': {
named: ['EuiExpression'],
},
},
customProps: {
onClick: dummyFunction,
},
},
};
};

0 comments on commit 0bf5673

Please sign in to comment.