Skip to content

Commit

Permalink
[Playground] EuiSpacer, EuiHorizontalRule (#3868)
Browse files Browse the repository at this point in the history
* [Playground] EuiSpacer, EuiHorizontalRule

* Update src-docs/src/services/playground/playground.js

Co-authored-by: Caroline Horn <[email protected]>

* Update playground.js

* Update playground.js

Co-authored-by: Caroline Horn <[email protected]>
  • Loading branch information
2 people authored and nyurik committed Aug 18, 2020
1 parent 4b5f7e0 commit e9c12ee
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src-docs/src/services/playground/playground.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useView, Compiler, Placeholder } from 'react-view';
import { EuiSpacer, EuiTitle, EuiCodeBlock } from '../../../../src/components';
import Knobs from './knobs';

export default ({ config, setGhostBackground }) => {
export default ({ config, setGhostBackground, playgroundClassName }) => {
const getSnippet = code => {
let regex = /return \(([\S\s]*?)(;)$/gm;
let newCode = code.match(regex);
Expand Down Expand Up @@ -45,9 +45,13 @@ export default ({ config, setGhostBackground }) => {
}
}, [params.knobProps]);

const compilerClasses = classNames('playgroundCompiler', {
playgroundCompiler__ghostBackground: isGhost,
});
const compilerClasses = classNames(
'playgroundCompiler',
{
playgroundCompiler__ghostBackground: isGhost,
},
playgroundClassName
);

return (
<React.Fragment>
Expand Down
3 changes: 3 additions & 0 deletions src-docs/src/views/horizontal_rule/horizontal_rule_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { GuideSectionTypes } from '../../components';

import { EuiHorizontalRule } from '../../../../src/components';

import { horizontalRuleConfig } from './playground';

import HorizontalRule from './horizontal_rule';
const horizontalRuleSource = require('!!raw-loader!./horizontal_rule');
const horizontalRuleHtml = renderToHtml(HorizontalRule);
Expand Down Expand Up @@ -64,4 +66,5 @@ export const HorizontalRuleExample = {
demo: <HorizontalRuleMargin />,
},
],
playground: horizontalRuleConfig,
};
24 changes: 24 additions & 0 deletions src-docs/src/views/horizontal_rule/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { EuiHorizontalRule } from '../../../../src/components/';
import { propUtilityForPlayground } from '../../services/playground';

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

return {
config: {
componentName: 'EuiHorizontalRule',
props: propsToUse,
scope: {
EuiHorizontalRule,
},
imports: {
'@elastic/eui': {
named: ['EuiHorizontalRule'],
},
},
},
};
};
25 changes: 25 additions & 0 deletions src-docs/src/views/spacer/playground.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { EuiSpacer } from '../../../../src/components/';
import { propUtilityForPlayground } from '../../services/playground';

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

return {
config: {
componentName: 'EuiSpacer',
props: propsToUse,
scope: {
EuiSpacer,
},
imports: {
'@elastic/eui': {
named: ['EuiSpacer'],
},
},
},
playgroundClassName: 'guideDemo__highlightSpacer',
};
};
3 changes: 3 additions & 0 deletions src-docs/src/views/spacer/spacer_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { GuideSectionTypes } from '../../components';

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

import { spacerConfig } from './playground';

import Spacer from './spacer';
const spacerSource = require('!!raw-loader!./spacer');
const spacerHtml = renderToHtml(Spacer);
Expand Down Expand Up @@ -48,4 +50,5 @@ export const SpacerExample = {
),
},
],
playground: spacerConfig,
};

0 comments on commit e9c12ee

Please sign in to comment.