-
Notifications
You must be signed in to change notification settings - Fork 840
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New EuiDelayRender component is introduced, please have a look at the documentation to find out how to use it. This is a HOC so you can just wrap with it what you want and get delayed rendering. Set a delay period in ms. Default is 500. <EuiDelayRender delay={400}> {...} </EuiDelayRender >
- Loading branch information
1 parent
cf4010a
commit 771830d
Showing
16 changed files
with
482 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import React, { Component, Fragment } from 'react'; | ||
import { | ||
EuiDelayRender, | ||
EuiFlexItem, | ||
EuiCheckbox, | ||
EuiFormRow, | ||
EuiFieldNumber, | ||
EuiLoadingSpinner, | ||
} from '../../../../src/components'; | ||
|
||
export default class extends Component { | ||
state = { | ||
minimumDelay: 3000, | ||
render: false, | ||
}; | ||
|
||
onChangeMinimumDelay = event => { | ||
this.setState({ minimumDelay: parseInt(event.target.value, 10) }); | ||
}; | ||
|
||
onChangeHide = event => { | ||
this.setState({ render: event.target.checked }); | ||
}; | ||
|
||
render() { | ||
const status = this.state.render ? 'showing' : 'hidden'; | ||
const label = `Child (${status})`; | ||
return ( | ||
<Fragment> | ||
<EuiFlexItem> | ||
<EuiFormRow> | ||
<EuiCheckbox | ||
id="dummy-id" | ||
checked={this.state.render} | ||
onChange={this.onChangeHide} | ||
label="Show child" | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Minimum delay"> | ||
<EuiFieldNumber | ||
value={this.state.minimumDelay} | ||
onChange={this.onChangeMinimumDelay} | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow label={label}> | ||
{this.state.render ? ( | ||
<EuiDelayRender delay={this.state.minimumDelay}> | ||
<EuiLoadingSpinner size="m" /> | ||
</EuiDelayRender> | ||
) : ( | ||
<Fragment /> | ||
)} | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
</Fragment> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import DelayRender from './delay_render'; | ||
import { GuideSectionTypes } from '../../components'; | ||
import { EuiCode, EuiDelayRender } from '../../../../src/components'; | ||
import { renderToHtml } from '../../services'; | ||
|
||
const delayRenderSource = require('!!raw-loader!./delay_render'); | ||
const delayRenderHtml = renderToHtml(DelayRender); | ||
|
||
export const DelayRenderExample = { | ||
title: 'Delay Render', | ||
sections: [ | ||
{ | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.JS, | ||
code: delayRenderSource, | ||
}, | ||
{ | ||
type: GuideSectionTypes.HTML, | ||
code: delayRenderHtml, | ||
}, | ||
], | ||
text: ( | ||
<p> | ||
<EuiCode>EuiDelayRender</EuiCode> is a component for conditionally | ||
toggling the visibility of a child component. It will ensure that the | ||
child is hidden for at least 500ms (default). This allows delay UI | ||
rendering. That is helpful when you need to update aria live region(s) | ||
repeatedly. | ||
</p> | ||
), | ||
props: { EuiDelayRender }, | ||
demo: <DelayRender />, | ||
}, | ||
], | ||
}; |
Oops, something went wrong.