Skip to content

Commit dbebb0d

Browse files
committed
add overview for tutorials
1 parent 8750e53 commit dbebb0d

File tree

2 files changed

+57
-16
lines changed

2 files changed

+57
-16
lines changed

src/components/docs/Doc.astro

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ function color(): string {
7373
<DocsFiche text={docType.type} color={color()}/>
7474
{[docType.deprecated].filter(x => x).map(x => <DocsFiche text="Deprecated" color="520f0f"/>)}
7575
{[docType.cancellable].filter(x => x).map(x => <DocsFiche text="Cancellable" color="112998"/>)}
76+
{[docType.requirements?.join("")].filter(x => x).map(x => {
77+
x = x?.replaceAll(/[.+0-9]/g, "")?.trim();
78+
79+
if (x?.toLowerCase() === "paper") {
80+
return <DocsFiche text="Paper" color="7d037f"/>;
81+
} else if (x?.toLowerCase().includes("paper")) {
82+
return <DocsFiche text="Partially Paper" color="7d037f"/>;
83+
} else {
84+
return null;
85+
}
86+
})}
7687

7788
<div class="id flex-auto relative -top-37" id={docType.id}></div> <!-- Anchor all the way up or else its in the nav bar -->
7889
<button class="share">

src/components/tutorials/TutorialsOverview.astro

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,55 @@ const { selected, tutorials }: Props = Astro.props;
1313
// Update position of filters to be below the nav bar,
1414
// since filters is sticky this cant be done directly
1515
document.getElementById("tutorials")!!.style.top = `${document.getElementById("nav")!!.offsetHeight}px`;
16+
17+
const tutorials = document.getElementById("tutorials-expand-area")!!;
18+
const expand = document.getElementById("tutorials-expand-button")!!;
19+
const expandIcon = document.getElementById("tutorials-overview-expand-icon")!!;
20+
expand.addEventListener("click", () => {
21+
tutorials.classList.toggle("hidden");
22+
tutorials.classList.toggle("flex");
23+
expandIcon.querySelector("svg")!!.classList.toggle("rotate-90");
24+
});
25+
26+
function updatePosition() {
27+
// Update position of filters to be below the nav bar,
28+
// since filters is sticky this cant be done directly
29+
tutorials.style.top = `${document.getElementById("nav")!!.offsetHeight}px`;
30+
}
31+
32+
window.addEventListener("DOMContentLoaded", updatePosition);
33+
window.addEventListener("resize", updatePosition);
1634
</script>
1735

18-
<div id="tutorials" class="sticky top-30 left-0 w-full md:w-64 md:h-[100vh] overflow-y-hidden p-4
36+
<div id="tutorials" class="sticky top-[118px] left-0 w-full md:w-64 md:h-[100vh] overflow-y-hidden p-4
1937
flex flex-col gap-2 shrink-0
2038
border-b-2 md:border-b-0 md:border-r-2 border-l-border dark:border-d-border
2139
bg-l-bg dark:bg-d-bg">
22-
{tutorials.map(x => {
23-
if (x.title === selected) {
24-
return <a href={`/tutorials/${x.id}`} class="text-left px-4 py-3 rounded-md
25-
bg-skript hover:cursor-pointer
26-
font-bold text-white">
27-
{x.title}
28-
</a>
29-
} else {
30-
return <a href={`/tutorials/${x.id}`} class="text-left px-4 py-3 rounded-md
31-
bg-l-bg-secondary dark:bg-d-bg-secondary hover:cursor-pointer
32-
font-bold">
33-
{x.title}
34-
</a>
35-
}
36-
})}
40+
<div id="tutorials-expand-button" class="p-4 -m-4 flex flex-row gap-2 hover:cursor-pointer">
41+
<h2 class="flex md:hidden">Overview</h2>
42+
<div class="flex-auto"></div>
43+
<button id="tutorials-overview-expand-icon" class="block md:hidden px-2 w-fit rounded-sm
44+
hover:cursor-pointer hover:opacity-80 transition">
45+
<svg class="transition rotate-90" width="18" height="18" viewBox="0 0 18 18" xmlns="http://www.w3.org/2000/svg">
46+
<path d="M8.60627 10.8563L5.88752 8.1375C5.85002 8.1 5.82202 8.0595 5.80352 8.016C5.78502 7.9725 5.77552 7.9255 5.77502 7.875C5.77502 7.775 5.80952 7.6875 5.87852 7.6125C5.94752 7.5375 6.03802 7.5 6.15002 7.5H11.85C11.9625 7.5 12.0533 7.5375 12.1223 7.6125C12.1913 7.6875 12.2255 7.775 12.225 7.875C12.225 7.9 12.1875 7.9875 12.1125 8.1375L9.39377 10.8563C9.33127 10.9188 9.26877 10.9625 9.20627 10.9875C9.14377 11.0125 9.07502 11.025 9.00002 11.025C8.92502 11.025 8.85627 11.0125 8.79377 10.9875C8.73127 10.9625 8.66877 10.9188 8.60627 10.8563Z"/>
47+
</svg>
48+
</button>
49+
</div>
50+
<div id="tutorials-expand-area" class="hidden sm:flex flex-col gap-2">
51+
{tutorials.map(x => {
52+
if (x.title === selected) {
53+
return <a href={`/tutorials/${x.id}`} class="text-left px-4 py-3 rounded-md
54+
bg-skript hover:cursor-pointer
55+
font-bold text-white">
56+
{x.title}
57+
</a>
58+
} else {
59+
return <a href={`/tutorials/${x.id}`} class="text-left px-4 py-3 rounded-md
60+
bg-l-bg-secondary dark:bg-d-bg-secondary hover:cursor-pointer
61+
font-bold">
62+
{x.title}
63+
</a>
64+
}
65+
})}
66+
</div>
3767
</div>

0 commit comments

Comments
 (0)