-
Notifications
You must be signed in to change notification settings - Fork 839
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
98 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React, { Component } from 'react'; | ||
import { EuiDelayHide } from '../../../../src/components/delay_hide'; | ||
import { EuiFlexItem } from '../../../../src/components/flex/flex_item'; | ||
import { EuiCheckbox } from '../../../../src/components/form/checkbox/checkbox'; | ||
import { EuiFormRow } from '../../../../src/components/form/form_row/form_row'; | ||
import { EuiFieldNumber } from '../../../../src/components/form/field_number'; | ||
|
||
export default class extends Component { | ||
state = { | ||
minimumDuration: 1000, | ||
hide: false | ||
}; | ||
|
||
onChangeMinimumDuration = event => { | ||
this.setState({ minimumDuration: parseInt(event.target.value, 10) }); | ||
}; | ||
|
||
onChangeHide = event => { | ||
this.setState({ hide: event.target.checked }); | ||
}; | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<EuiFlexItem> | ||
<EuiFormRow> | ||
<EuiCheckbox | ||
id="dummy-id" | ||
checked={this.state.hide} | ||
onChange={this.onChangeHide} | ||
label="Hide child" | ||
/> | ||
</EuiFormRow> | ||
<EuiFormRow label="Minimum duration"> | ||
<EuiFieldNumber | ||
value={this.state.minimumDuration} | ||
onChange={this.onChangeMinimumDuration} | ||
/> | ||
</EuiFormRow> | ||
|
||
<EuiFormRow label="Child to render"> | ||
<EuiDelayHide | ||
hide={this.state.hide} | ||
minimumDuration={this.state.minimumDuration} | ||
render={() => <div>Hello world</div>} | ||
/> | ||
</EuiFormRow> | ||
</EuiFlexItem> | ||
</div> | ||
); | ||
} | ||
} |
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,38 @@ | ||
import React from 'react'; | ||
import DelayHide from './delay_hide'; | ||
import { GuideSectionTypes } from '../../components'; | ||
import { EuiCode, EuiDelayHide } from '../../../../src/components'; | ||
import { renderToHtml } from '../../services'; | ||
|
||
const delayHideSource = require('!!raw-loader!./delay_hide'); | ||
const delayHideHtml = renderToHtml(DelayHide); | ||
|
||
export const DelayHideExample = { | ||
title: 'DelayHide', | ||
sections: [ | ||
{ | ||
title: 'DelayHide', | ||
source: [ | ||
{ | ||
type: GuideSectionTypes.JS, | ||
code: delayHideSource | ||
}, | ||
{ | ||
type: GuideSectionTypes.HTML, | ||
code: delayHideHtml | ||
} | ||
], | ||
text: ( | ||
<p> | ||
<EuiCode>DelayHide</EuiCode> is a component for conditionally toggling | ||
the visibility of a child component. It will ensure that the child is | ||
visible for at least 1000ms (default). This avoids UI glitches that | ||
are common with loading spinners and other elements that are rendered | ||
conditionally and potentially for a short amount of time. | ||
</p> | ||
), | ||
props: { EuiDelayHide }, | ||
demo: <DelayHide /> | ||
} | ||
] | ||
}; |
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