Skip to content

Commit

Permalink
[Playground] EuiLink (#3862)
Browse files Browse the repository at this point in the history
  • Loading branch information
anishagg17 authored and nyurik committed Aug 18, 2020
1 parent 08476f0 commit 4470046
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src-docs/src/views/link/link_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { GuideSectionTypes } from '../../components';

import { EuiCode, EuiLink } from '../../../../src/components';

import linkConfig from './playground';

import Link from './link';
import { LinkDisable } from './link_disable';

Expand Down Expand Up @@ -76,4 +78,5 @@ export const LinkExample = {
demo: <LinkDisable />,
},
],
playground: linkConfig,
};
70 changes: 70 additions & 0 deletions src-docs/src/views/link/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { PropTypes } from 'react-view';
import { EuiLink } from '../../../../src/components/';
import { propUtilityForPlayground } from '../../services/playground';
import * as t from '@babel/types';

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

propsToUse.href = {
type: PropTypes.String,
value: 'http://www.elastic.co',
};
propsToUse.target = {
type: PropTypes.String,
value: '_blank',
};

propsToUse.children = {
value: 'Link to our website',
type: PropTypes.String,
hidden: false,
};

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

const setGhostBackground = {
color: 'ghost',
};

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

0 comments on commit 4470046

Please sign in to comment.