diff --git a/src-docs/src/views/loading/loading_example.js b/src-docs/src/views/loading/loading_example.js index 0f42ebf92324..330def95fe48 100644 --- a/src-docs/src/views/loading/loading_example.js +++ b/src-docs/src/views/loading/loading_example.js @@ -7,6 +7,7 @@ import { } from '../../components'; import { + EuiCode, EuiLoadingKibana, EuiLoadingSpinner, EuiLoadingChart, @@ -86,7 +87,7 @@ export const LoadingExample = { demo: , snippet: `` }, { - title: 'Content', + title: 'Text Content', source: [{ type: GuideSectionTypes.JS, code: loadingContentSource, @@ -95,7 +96,7 @@ export const LoadingExample = { code: loadingContentHtml, }], text: ( -

A simple loading animation for displaying placeholder content. You can pass in a number of lines — the default is 3.

+

A simple loading animation for displaying placeholder text content. You can pass in a number of lines between 1 and 10.

), props: { EuiLoadingContent }, demo: , diff --git a/src/components/loading/loading_content.tsx b/src/components/loading/loading_content.tsx index 108412d75e21..a7ab9abe4706 100644 --- a/src/components/loading/loading_content.tsx +++ b/src/components/loading/loading_content.tsx @@ -1,6 +1,9 @@ import React, { FunctionComponent, HTMLAttributes } from 'react'; import classNames from 'classnames'; import { CommonProps } from '../common'; +import { htmlIdGenerator } from '../../services'; + +const getMaskId = htmlIdGenerator('euiLoadingContent__mask--'); export const EuiLoadingContent: FunctionComponent< CommonProps & @@ -9,28 +12,29 @@ export const EuiLoadingContent: FunctionComponent< } > = ({ lines = 3, className, ...rest }) => { const classes = classNames('euiLoadingContent', className); - // We need an array for mapping the lines - const newLineArray = Array(lines).fill(undefined); + const maskId = getMaskId(); + const lineElements = []; + for (let i = 0; i < lines; i++) { + lineElements.push( + + ); + } return ( -
+ // TODO: Remove the styles! They're only there for 👇development +
- - {newLineArray.map((line: undefined, index) => { - return ( - - ); - })} - + {lineElements}