-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: support loading state in combobox and menu
- Loading branch information
Showing
16 changed files
with
3,659 additions
and
3,763 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<auro-combobox id="loadingExample"> | ||
<span slot="label">Please select a preference</span> | ||
<auro-menu id="loadingExampleComboboxMenu"> | ||
<auro-loader slot="loadingIcon" orbit xs></auro-loader><span slot="loadingText">Loading...</span> | ||
</auro-menu> | ||
</auro-combobox> |
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,34 @@ | ||
export function auroMenuLoadingExample() { | ||
const combobox = document.querySelector("#loadingExample"); | ||
const menu = document.querySelector("#loadingExampleComboboxMenu"); | ||
const emptyMenu = () => { | ||
const menuoptions = menu.querySelectorAll('auro-menuoption'); | ||
menuoptions.forEach(mo => menu.removeChild(mo)); | ||
} | ||
const fillMenu = () => { | ||
menu.innerHTML += ` | ||
<auro-menuoption value="Apples" id="option-0">Apples</auro-menuoption> | ||
<auro-menuoption value="Oranges" id="option-1">Oranges</auro-menuoption> | ||
<auro-menuoption value="Peaches" id="option-2">Peaches</auro-menuoption> | ||
<auro-menuoption value="Grapes" id="option-3">Grapes</auro-menuoption> | ||
<auro-menuoption value="Cherries" id="option-4">Cherries</auro-menuoption> | ||
<auro-menuoption static nomatch>No matching option</auro-menuoption> | ||
`; | ||
} | ||
|
||
const load = () => { | ||
clearTimeout(load.id); | ||
emptyMenu(); | ||
menu.setAttribute('loading', 'loading'); | ||
load.id = setTimeout(() => { | ||
menu.removeAttribute('loading'); | ||
fillMenu(); | ||
}, 1000); | ||
|
||
} | ||
combobox.addEventListener("input", (e) => { | ||
if (e.target.value) { | ||
load(); | ||
} | ||
}); | ||
} |
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
Oops, something went wrong.