Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
4 changes: 3 additions & 1 deletion src-docs/src/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,9 @@ const createExample = (example, customTitle) => {

let playgroundComponent;
if (playground) {
playgroundComponent = playgroundCreator(playground());
if (Array.isArray(playground)) {
playgroundComponent = playground.map(elm => playgroundCreator(elm()));
} else playgroundComponent = playgroundCreator(playground());
}

const component = () => (
Expand Down
6 changes: 6 additions & 0 deletions src-docs/src/views/badge/badge_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ import {
EuiBadgeGroup,
EuiCallOut,
} from '../../../../src/components';
import {
badgeConfig,
betaBadgeConfig,
notificationBadgeConfig,
} from './playground';

import Badge from './badge';

Expand Down Expand Up @@ -317,4 +322,5 @@ export const BadgeExample = {
demo: <NotificationBadge />,
},
],
playground: [badgeConfig, betaBadgeConfig, notificationBadgeConfig],
};
128 changes: 128 additions & 0 deletions src-docs/src/views/badge/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import { PropTypes } from 'react-view';
import {
EuiBadge,
EuiNotificationBadge,
EuiBetaBadge,
} from '../../../../src/components/';
import {
propUtilityForPlayground,
mapOptions,
} from '../../services/playground';
import { iconTypes } from '../icon/icons';

const iconOptions = mapOptions(iconTypes);

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

propsToUse.onClick = {
Comment thread
anishagg17 marked this conversation as resolved.
...propsToUse.onClick,
value: "() => console.log('Clicked')",
};

propsToUse.children = {
Comment thread
anishagg17 marked this conversation as resolved.
type: PropTypes.String,
value: 'badge content',
Comment thread
anishagg17 marked this conversation as resolved.
Outdated
hidden: true,
};

propsToUse.iconType = {
...propsToUse.iconType,
value: undefined,
type: PropTypes.String,
custom: {
...propsToUse.iconType.custom,
validator: val => iconOptions[val],
},
};
Comment thread
anishagg17 marked this conversation as resolved.

propsToUse.color = {
...propsToUse.color,
value: undefined,
type: PropTypes.String,
};
Comment thread
anishagg17 marked this conversation as resolved.

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

export const betaBadgeConfig = () => {
Comment thread
anishagg17 marked this conversation as resolved.
const docgenInfo = Array.isArray(EuiBetaBadge.__docgenInfo)
? EuiBetaBadge.__docgenInfo[0]
: EuiBetaBadge.__docgenInfo;
const propsToUse = propUtilityForPlayground(docgenInfo.props);

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

propsToUse.iconType = {
...propsToUse.iconType,
value: undefined,
type: PropTypes.String,
custom: {
...propsToUse.iconType.custom,
validator: val => iconOptions[val],
},
};

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

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

propsToUse.children = {
type: PropTypes.String,
value: 'badge content',
Comment thread
anishagg17 marked this conversation as resolved.
Outdated
hidden: true,
};

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