generated from ITZSHOAIB/typescript-library-starter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoutput.html
66 lines (60 loc) · 2.49 KB
/
output.html
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<head><style>
.rehype-code-group {
display: grid;
gap: 0.6rem;
}
.rcg-tab-container {
display: flex;
border-bottom: 1px solid #ddd;
}
.rcg-tab {
padding: 0.5rem 1rem;
cursor: pointer;
border: none;
background: none;
&.active {
border-bottom: 2px solid;
font-weight: bold;
}
}
.rcg-block {
display: none;
overflow-x: auto;
&.active {
display: block;
}
}
</style><script type="text/javascript">
document.addEventListener("DOMContentLoaded", function () {
const codeGroups = document.querySelectorAll(".rehype-code-group");
codeGroups.forEach((group) => {
const tabs = group.querySelectorAll(".rcg-tab");
const blocks = group.querySelectorAll(".rcg-block");
let activeTab = group.querySelector(".rcg-tab.active");
let activeBlock = group.querySelector(".rcg-block.active");
group.addEventListener("click", (event) => {
const tab = event.target.closest(".rcg-tab");
if (!tab) return;
const index = Array.from(tabs).indexOf(tab);
if (index === -1) return;
if (activeTab) {
activeTab.classList.remove("active");
activeTab.setAttribute("aria-selected", "false");
}
if (activeBlock) {
activeBlock.classList.remove("active");
activeBlock.setAttribute("hidden", "true");
}
tab.classList.add("active");
tab.setAttribute("aria-selected", "true");
blocks[index].classList.add("active");
blocks[index].removeAttribute("hidden");
activeTab = tab;
activeBlock = blocks[index];
});
});
});
</script></head><div class="rehype-code-group"><div class="rcg-tab-container" role="tablist"><button class="rcg-tab active" role="tab" aria-selected="true" aria-controls="rcg-5-block-0" id="rcg-5-tab-0">npm</button><button class="rcg-tab" role="tab" aria-selected="false" aria-controls="rcg-5-block-1" id="rcg-5-tab-1">pnpm</button><button class="rcg-tab" role="tab" aria-selected="false" aria-controls="rcg-5-block-2" id="rcg-5-tab-2">yarn</button></div><div class="rcg-block active" role="tabpanel" aria-labelledby="rcg-5-tab-0" id="rcg-5-block-0"><pre><code class="language-bash">npm install rehype-code-group
</code></pre></div><div class="rcg-block" role="tabpanel" aria-labelledby="rcg-5-tab-1" id="rcg-5-block-1" hidden><pre><code class="language-bash">pnpm add rehype-code-group
</code></pre></div><div class="rcg-block" role="tabpanel" aria-labelledby="rcg-5-tab-2" id="rcg-5-block-2" hidden><pre><code class="language-bash">yarn add rehype-code-group
</code></pre></div></div>