Skip to content
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
35 changes: 26 additions & 9 deletions src-docs/src/components/guide_section/guide_section.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,28 @@ export class GuideSection extends Component {
return;
}

return [
<Fragment key="snippet">
<EuiSpacer size="m" />
<EuiCodeBlock language="html" fontSize="m" paddingSize="m" isCopyable>
{snippet}
</EuiCodeBlock>
</Fragment>
];
let snippetCode;
if (typeof snippet === 'string') {
snippetCode = (
<Fragment key="snippet">
<EuiSpacer size="m" />
<EuiCodeBlock language="html" fontSize="m" paddingSize="m" isCopyable>
{snippet}
</EuiCodeBlock>
</Fragment>
);
} else {
snippetCode = snippet.map((snip, index) => (
<Fragment key={`snippet${index}`}>
<EuiSpacer size="m" />
<EuiCodeBlock language="html" fontSize="m" paddingSize="m" isCopyable>
{snip}
</EuiCodeBlock>
</Fragment>
));
}

return snippetCode;
}

renderPropsForComponent = (componentName, component) => {
Expand Down Expand Up @@ -413,7 +427,10 @@ GuideSection.propTypes = {
title: PropTypes.string,
id: PropTypes.string,
source: PropTypes.array,
snippet: PropTypes.string,
snippet: PropTypes.oneOfType([
PropTypes.string,
PropTypes.arrayOf(PropTypes.string),
]),
children: PropTypes.any,
toggleTheme: PropTypes.func.isRequired,
theme: PropTypes.string.isRequired,
Expand Down
29 changes: 11 additions & 18 deletions src-docs/src/views/icon/icon_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,23 @@ const iconsSnippet = `<EuiIcon type="alert" />`;

import Tokens from './tokens';
const tokensSource = require('!!raw-loader!./tokens');
const tokensSnippet = `<EuiToken type="tokenAnnotation" />

<EuiToken
const tokensSnippet = [`<EuiToken type="tokenAnnotation" />`,
`<EuiToken
iconType="visMapCoordinate"
displayOptions={{
color: 'tokenTint05',
shape: 'circle',
}}
/>

<EuiToken
/>`,
`<EuiToken
iconType="tokenElement"
size="l"
displayOptions={{
color: 'tokenTint07',
shape: 'rectangle',
hideBorder: true
}}
/>`;
/>`];


import Apps from './apps';
Expand All @@ -74,23 +72,18 @@ const iconSizesSnippet = `<EuiIcon type="logoElasticStack" size="xl" />`;

import IconColors from './icon_colors';
const iconColorsSource = require('!!raw-loader!./icon_colors');
const iconColorsSnippet = `<EuiIcon type="brush" color="primary" />

<EuiIcon type="brush" color="#F98510" />`;
const iconColorsSnippet = [`<EuiIcon type="brush" color="primary" />`,
`<EuiIcon type="brush" color="#F98510" />`];

import Accessibility from './accessibility';
const accessibilitySource = require('!!raw-loader!./accessibility');

import IconTypes from './icon_types';
const iconTypesSource = require('!!raw-loader!./icon_types');
const iconTypesSnippet = `<EuiIcon type="logoElastic" size="xl" />

<EuiIcon type={reactSVGElement} size="xl" />

<EuiIcon type="https://upload.wikimedia.org/wikipedia/commons/9/9f/Vimlogo.svg" size="xl" />

<EuiButton iconType={reactSVGElement}>Works in other components too</EuiButton>
`;
const iconTypesSnippet = [`<EuiIcon type="logoElastic" size="xl" />`,
`<EuiIcon type={reactSVGElement} size="xl" />`,
`<EuiIcon type="https://upload.wikimedia.org/wikipedia/commons/9/9f/Vimlogo.svg" size="xl" />`,
`<EuiButton iconType={reactSVGElement}>Works in other components too</EuiButton>`];

export const IconExample = {
title: 'Icons',
Expand Down