Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add alerts to refresh buttons #2935

Merged
merged 3 commits into from
Jan 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 27 additions & 15 deletions stories/components/get/get.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,27 +184,39 @@ export const PollingRate = () => html`
`;

export const refresh = () => html`
<mgt-get cache-enabled="true" resource="/me" version="beta">
<template data-type="default"> {{ this.displayName }}</template>
<template data-type="loading">
<h2>Loading...?!?!</h2>
</template>
</mgt-get>

<div>
<label>get.refresh(false)</label>
<button id="false">Soft refresh</button>
</div>
<label>get.refresh(true)</label>
<button id="true">Hard refresh</button>
<div>
<label>get.refresh(true)</label>
<button id="true">Hard refresh</button>
</div>

<mgt-get cache-enabled="true" resource="/me/messages" version="beta">
gavinbarron marked this conversation as resolved.
Show resolved Hide resolved
<template data-type="default"> {{ this }}</template>
<template data-type="loading">
<h2>Loading...?!?!</h2>
</template>
</mgt-get>

<script>
document.querySelector('#false').addEventListener('click', _ =>{
document.querySelector('mgt-get').refresh(false)
})
const softRefreshButton = document.querySelector('#false');
const hardRefreshButton = document.querySelector('#true');
const getElement = document.querySelector('mgt-get');

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);
};

softRefreshButton.addEventListener('click', softRefresh)

document.querySelector('#true').addEventListener('click', _ =>{
document.querySelector('mgt-get').refresh(true)
})
hardRefreshButton.addEventListener('click', hardRefresh)
</script>
`;
Loading