@@ -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