-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert EuiStat to TSX, add isLoading prop, add tests (#1848)
Adds an `isLoading` prop to `EuiStat`. Changes it to TS and adds a bunch of tests. Also fixes several accessibility issues.
- Loading branch information
Showing
14 changed files
with
818 additions
and
234 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 |
---|---|---|
@@ -1,63 +1,93 @@ | ||
import React from 'react'; | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import { | ||
EuiStat, | ||
EuiFlexItem, | ||
EuiFlexGroup, | ||
EuiPanel, | ||
EuiIcon, | ||
EuiSwitch, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="8,888" | ||
description="Total widgets" | ||
textAlign="right" | ||
> | ||
<EuiIcon type="empty" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="2,000" | ||
description="Pending widgets" | ||
titleColor="accent" | ||
textAlign="right" | ||
> | ||
<EuiIcon type="clock" color="accent" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="6,800" | ||
description="Success widgets" | ||
titleColor="secondary" | ||
textAlign="right" | ||
> | ||
<EuiIcon type="check" color="secondary" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="88" | ||
description="Error widgets" | ||
titleColor="danger" | ||
textAlign="right" | ||
> | ||
<EuiIcon type="alert" color="danger" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
</div> | ||
); | ||
export default class extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
isLoading: false, | ||
}; | ||
} | ||
|
||
onToggleChange = (e) => { | ||
this.setState({ isLoading: e.target.checked }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<EuiFlexGroup> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="8,888" | ||
description="Total widgets" | ||
textAlign="right" | ||
isLoading={this.state.isLoading} | ||
> | ||
<EuiIcon type="empty" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="2,000" | ||
description="Pending widgets" | ||
titleColor="accent" | ||
textAlign="right" | ||
isLoading={this.state.isLoading} | ||
> | ||
<EuiIcon type="clock" color="accent" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="6,800" | ||
description="Success widgets" | ||
titleColor="secondary" | ||
textAlign="right" | ||
isLoading={this.state.isLoading} | ||
> | ||
<EuiIcon type="check" color="secondary" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
<EuiFlexItem> | ||
<EuiPanel> | ||
<EuiStat | ||
title="88" | ||
description="Error widgets" | ||
titleColor="danger" | ||
textAlign="right" | ||
isLoading={this.state.isLoading} | ||
> | ||
<EuiIcon type="alert" color="danger" /> | ||
</EuiStat> | ||
</EuiPanel> | ||
</EuiFlexItem> | ||
</EuiFlexGroup> | ||
<EuiSpacer /> | ||
<EuiSwitch | ||
label="Show as loading" | ||
checked={this.state.isLoading} | ||
onChange={this.onToggleChange} | ||
/> | ||
</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
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,41 @@ | ||
import React, { | ||
Component, | ||
} from 'react'; | ||
|
||
import { | ||
EuiSwitch, | ||
EuiStat, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default class extends Component { | ||
constructor(props) { | ||
super(props); | ||
|
||
this.state = { | ||
isLoading: true, | ||
}; | ||
} | ||
|
||
onToggleChange = (e) => { | ||
this.setState({ isLoading: e.target.checked }); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div> | ||
<EuiStat | ||
title="7,600 mm" | ||
description="Total People" | ||
isLoading={this.state.isLoading} | ||
/> | ||
<EuiSpacer /> | ||
<EuiSwitch | ||
label="Show as loading" | ||
checked={this.state.isLoading} | ||
onChange={this.onToggleChange} | ||
/> | ||
</div> | ||
); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.