Skip to content

Commit

Permalink
docs: make refresh buttons have apparent actions
Browse files Browse the repository at this point in the history
adds alerts to make actions apparent

Closes #2349
  • Loading branch information
gavinbarron committed Jan 4, 2024
1 parent 81d124b commit 2b4b2e1
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions stories/components/get/get.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,29 +185,39 @@ export const PollingRate = () => html`
`;

export const refresh = () => html`
<mgt-get cache-enabled="true" resource="/me/presence" version="beta" scopes="Presence.Read">
<template data-type="default"> {{availability}} </template>
<template data-type="loading">
<h2>Loading...?!?!</h2>
</template>
</mgt-get>
<div>
<label>get.refresh(false)</label>
<button id="false">Soft refresh</button>
</div>
<div>
<label>get.refresh(false)</label>
<button id="false">Soft refresh</button>
</div>
<div>
<label>get.refresh(true)</label>
<button id="true">Hard refresh</button>
</div>
<mgt-get cache-enabled="true" resource="/me/messages" version="beta">
<template data-type="default"> {{ this }}</template>
<template data-type="loading">
<h2>Loading...?!?!</h2>
</template>
</mgt-get>
<script>
const softRefreshButton = document.querySelector('#false');
const hardRefreshButton = document.querySelector('#true');
const getElement = document.querySelector('mgt-get');
<script>
const softRefresh = () => {
alert('requesting soft refresh of mgt-get component');
getElement.refresh(false);
};
const hardRefresh = () => {
alert('requesting hard refresh of mgt-get component');
getElement.refresh(true);
};
document.querySelector('#false').addEventListener('click', _ =>{
document.querySelector('mgt-get').refresh(false)
})
softRefreshButton.addEventListener('click', softRefresh)
document.querySelector('#true').addEventListener('click', _ =>{
document.querySelector('mgt-get').refresh(true)
})
</script>
hardRefreshButton.addEventListener('click', hardRefresh)
</script>
`;

0 comments on commit 2b4b2e1

Please sign in to comment.