Skip to content

Commit 9728b9e

Browse files
committed
docs: sync html-lit-react tabs
1 parent 956bf1b commit 9728b9e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

docs/components/components.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,27 @@
1515
}
1616
---
1717

18+
<script type="module">
19+
const LS_KEY = 'html-lit-react-snippets-index';
20+
document.addEventListener('expand', async function(event) {
21+
const PfTabs = await customElements.whenDefined('pf-tabs');
22+
if (PfTabs.isExpandEvent(event)) {
23+
const tabs = event.target.closest('pf-tabs');
24+
await tabs.updateComplete;
25+
debugger;
26+
localStorage.setItem(LS_KEY, tabs.activeIndex);
27+
update();
28+
}
29+
});
30+
async function update() {
31+
for (const tabs of document.querySelectorAll('pf-tabs.html-lit-react-snippets')) {
32+
await tabs.updateComplete;
33+
tabs.activeIndex = parseInt(localStorage.getItem(LS_KEY) ?? '0');
34+
}
35+
}
36+
update();
37+
</script>
38+
1839
<header class="band">
1940
<h1>{{element.title}}</h1>
2041

0 commit comments

Comments
 (0)