Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiCodeBlock] Virtualized option #4952

Merged
merged 16 commits into from
Jul 26, 2021
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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**

34 changes: 33 additions & 1 deletion src-docs/src/views/code/code_example.js
Original file line number Diff line number Diff line change
@@ -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);
@@ -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
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
@@ -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
reduce the number of rendered rows and improve load times. Note that{' '}
<EuiCode>overflowHeight</EuiCode> is required when using this
configuration.
</p>
),
props: { EuiCodeBlock },
snippet: codeBlockVirtualizedSnippet,
demo: <CodeBlockVirtualized />,
},
{
title: 'Code block and white-space',
source: [
Loading