generated from adobe/aem-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
/
api-test.js
45 lines (36 loc) · 1.74 KB
/
api-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { PLUGIN_EVENTS } from 'https://main--franklin-library-host--dylandepass.hlx.live/tools/sidekick/library/events/events.js';
export async function decorate(container, data, query) {
const group = document.createElement('sp-button-group');
group.setAttribute('vertical', '');
const positiveToastButton = document.createElement('sp-button');
positiveToastButton.setAttribute('variant', 'primary');
positiveToastButton.textContent = 'Positive Toast';
group.append(positiveToastButton);
positiveToastButton.addEventListener('click', () => {
container.dispatchEvent(new CustomEvent(PLUGIN_EVENTS.TOAST, { detail: { message: 'Toast Shown!' } }))
});
const negativeToastButton = document.createElement('sp-button');
negativeToastButton.setAttribute('variant', 'negative');
negativeToastButton.textContent = 'Negative Toast';
group.append(negativeToastButton);
negativeToastButton.addEventListener('click', () => {
container.dispatchEvent(new CustomEvent(PLUGIN_EVENTS.TOAST, { detail: { message: 'Toast Shown!', variant: 'negative' } }))
});
const showLoaderButton = document.createElement('sp-button');
showLoaderButton.setAttribute('variant', 'primary');
showLoaderButton.textContent = 'Show Loader';
group.append(showLoaderButton);
showLoaderButton.addEventListener('click', () => {
group.style.display = 'none';
container.dispatchEvent(new CustomEvent(PLUGIN_EVENTS.SHOW_LOADER))
setTimeout(() => {
group.style.display = 'inline-flex';
container.dispatchEvent(new CustomEvent(PLUGIN_EVENTS.HIDE_LOADER))
}, 2000);
});
container.append(group);
}
export default {
title: 'API Test',
searchEnabled: false,
};