Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

- Refactored `EuiFlyout` types ([#4940](https://github.com/elastic/eui/pull/4940))
- Updated `pause` icon ([#4947](https://github.com/elastic/eui/pull/4947))
- Added optional virtualized line rendering to `EuiCodeBlock` ([#4952](https://github.com/elastic/eui/pull/4952))

**Bug fixes**

Expand Down
34 changes: 33 additions & 1 deletion src-docs/src/views/code/code_example.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const codeBlockSnippet = `<EuiCodeBlock language="html" paddingSize="s" isCopyab
</EuiCodeBlock>
`;

import CodeBlockVirtualized from './virtualized';
const codeBlockVirtualizedSource = require('!!raw-loader!./virtualized');
const codeBlockVirtualizedHtml = renderToHtml(CodeBlockVirtualized);
const codeBlockVirtualizedSnippet = `<EuiCodeBlock language="json" isVirtualized overflowHeight={300}>
{ \`{}\` }
</EuiCodeBlock>
`;

import CodeBlockPre from './code_block_pre';
const codeBlockPreSource = require('!!raw-loader!./code_block_pre');
const codeBlockPreHtml = renderToHtml(CodeBlockPre);
Expand All @@ -37,7 +45,7 @@ export const CodeExample = {
<p>
The <strong>EuiCode</strong> and <strong>EuiCodeBlock</strong>{' '}
components support{' '}
<EuiLink external href="https://github.com/wooorm/refractor#syntaxes">
<EuiLink external href="https://prismjs.com/#supported-languages">

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No language changes here. Just being consistent on links to prismjs vs. refractor

all language syntaxes
</EuiLink>{' '}
supported by the
Expand Down Expand Up @@ -108,6 +116,30 @@ export const CodeExample = {
demo: <CodeBlock />,
playground: codeBlockConfig,
},
{
title: 'Code block virtualization',
source: [
{
type: GuideSectionTypes.JS,
code: codeBlockVirtualizedSource,
},
{
type: GuideSectionTypes.HTML,
code: codeBlockVirtualizedHtml,
},
],
text: (
<p>
For large blocks of code, set <EuiCode>isVirtualized</EuiCode> to
Comment thread
thompsongl marked this conversation as resolved.
Outdated
reduce the number of rendered rows and improve load times. Note that{' '}
<EuiCode>overflowHeight</EuiCode> is required when using this
Comment thread
cchaos marked this conversation as resolved.
configuration.
</p>
),
props: { EuiCodeBlock },
snippet: codeBlockVirtualizedSnippet,
demo: <CodeBlockVirtualized />,
},
{
title: 'Code block and white-space',
source: [
Expand Down
Loading