-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(split-button): add loading properties
- Loading branch information
1 parent
d3dc006
commit 5f756b1
Showing
4 changed files
with
93 additions
and
1 deletion.
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
70 changes: 70 additions & 0 deletions
70
src/components/split-button/examples/split-button-loading.tsx
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,70 @@ | ||
import { Component, h, State } from '@stencil/core'; | ||
import { ListSeparator, MenuItem } from '@limetech/lime-elements'; | ||
|
||
/** | ||
* Split button with loading | ||
* | ||
* | ||
*/ | ||
@Component({ | ||
tag: 'limel-example-split-button-loading', | ||
shadow: true, | ||
}) | ||
export class SplitButtonLoadingExample { | ||
@State() | ||
private loading = false; | ||
|
||
@State() | ||
private disabled = false; | ||
|
||
@State() | ||
private loadingFailed = false; | ||
private items: Array<ListSeparator | MenuItem> = [ | ||
{ text: 'Later today', secondaryText: 'at 16:45' }, | ||
{ text: 'Tomorrow', secondaryText: 'at 08:00' }, | ||
]; | ||
|
||
public render() { | ||
return ( | ||
<limel-split-button | ||
primary={true} | ||
loading={this.loading} | ||
loadingFailed={this.loadingFailed} | ||
disabled={this.disabled} | ||
label="Send" | ||
icon="send" | ||
items={this.items} | ||
onClick={this.onClick} | ||
onSelect={this.handleSelect} | ||
/> | ||
); | ||
} | ||
|
||
private onClick = () => { | ||
console.log('Button clicked.'); | ||
this.disabled = true; | ||
this.loading = true; | ||
this.loadingFailed = false; | ||
|
||
const TIME_LOADING = 2000; | ||
setTimeout(() => { | ||
this.loading = false; | ||
this.disabled = false; | ||
this.loadingFailed = false; | ||
}, TIME_LOADING); | ||
}; | ||
|
||
private handleSelect = (event: CustomEvent<MenuItem>) => { | ||
console.log('Menu item chosen', event.detail.text); | ||
this.loading = true; | ||
this.disabled = true; | ||
this.loadingFailed = false; | ||
|
||
const TIME_LOADING = 2000; | ||
setTimeout(() => { | ||
this.loading = false; | ||
this.disabled = false; | ||
this.loadingFailed = false; | ||
}, TIME_LOADING); | ||
}; | ||
} |
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