diff --git a/src/components/code-sample.css b/src/components/code-sample.css index 951b08f..59a3e5c 100644 --- a/src/components/code-sample.css +++ b/src/components/code-sample.css @@ -6,6 +6,16 @@ width: 75%; } +@media (max-width: 829px) { + .code-sample { + width: 95%; + } + + .code-sample-result { + width: 95%; + } +} + .code-sample-result .result-content { margin-left: 0.75em; margin-right: 0.75em; @@ -15,4 +25,5 @@ justify-content: center; align-items: center; flex: 1; + max-width: 100%; } diff --git a/src/components/example.css b/src/components/example.css index 48744cb..24a30e1 100644 --- a/src/components/example.css +++ b/src/components/example.css @@ -1,15 +1,37 @@ .example-section { - width: calc(85vw - 200px); + width: clamp(550px, 65vw, 80vw); align-items: center; padding-bottom: 2em; } +.example-section-content { + max-width: 100%; +} + .example-section p { place-self: flex-start; margin-left: calc(12.5%); max-width: 75%; } +@media (max-width: 829px) { + .example-section.example-section { + width: clamp(350px, 80vw, 95vw); + padding-left: 0.25em; + padding-right: 0.25em; + } + + .example-section.example-section p { + margin-left: calc(12.5% - 0.7 * 2.85em); + max-width: 95%; + } + + .example-section.example-section h5 { + max-width: 95%; + margin-top: 0.2em; + } +} + .example-section h5 { place-self: flex-start; margin-left: calc(12.5% - 0.7 * 2.85em); diff --git a/src/components/example.tsx b/src/components/example.tsx index b051d1f..47c7f2d 100644 --- a/src/components/example.tsx +++ b/src/components/example.tsx @@ -54,7 +54,7 @@ export function ExampleSection( )} {props.description &&

{props.description}

} -
{props.children}
+
{props.children}
); } diff --git a/src/components/navbar-button.client.tsx b/src/components/navbar.client.tsx similarity index 57% rename from src/components/navbar-button.client.tsx rename to src/components/navbar.client.tsx index 0465864..cb13b77 100644 --- a/src/components/navbar-button.client.tsx +++ b/src/components/navbar.client.tsx @@ -4,6 +4,23 @@ declare global { const htmx: typeof HTMX; } +let MobileNavbarModal: HTMLDialogElement | null = null; + +const initMobileMenu = () => { + const dialog = document.querySelector("dialog")!; + const btn = document.querySelector(".navbar-mobile-btn")!; + btn.addEventListener("click", () => { + dialog.showModal(); + }); + + const backdropArea = document.querySelector(".navbar-overlay-backdrop")!; + backdropArea.addEventListener("click", () => { + dialog.close(); + }); + + MobileNavbarModal = dialog; +}; + class NavbarButton extends HTMLAnchorElement { onHistoryPush = (e: Event) => { const { path } = (e as CustomEvent<{ path: string }>).detail; @@ -15,6 +32,8 @@ class NavbarButton extends HTMLAnchorElement { } else { innerBtn.classList.remove("active"); } + + MobileNavbarModal?.close(); }; connectedCallback() { @@ -27,3 +46,4 @@ class NavbarButton extends HTMLAnchorElement { } window.customElements.define("navbar-button", NavbarButton, { extends: "a" }); +window.addEventListener("load", initMobileMenu); diff --git a/src/components/navbar.css b/src/components/navbar.css index e003354..d7cbf49 100644 --- a/src/components/navbar.css +++ b/src/components/navbar.css @@ -4,6 +4,7 @@ left: 0; height: 100vh; margin: 0px 0.3em; + width: clamp(200px, 20vw, 320px); } .left-navbar > .nav-sidebar { @@ -19,7 +20,6 @@ } .nav-sidebar.nav-sidebar { - width: 14em; justify-content: flex-start; } @@ -37,3 +37,52 @@ a.navbar-link, a.navbar-link button { cursor: pointer; } + +@media (max-width: 829px) { + .left-navbar.left-navbar { + display: none; + } + + .left-navbar-mobile.left-navbar-mobile { + display: block; + } + + .navbar-container { + position: sticky; + top: 0; + left: 0; + } +} + +.left-navbar-mobile { + display: none; + width: 100vw; + z-index: 10; +} + +.left-navbar-mobile dialog { + border: unset; + margin: unset; + padding: unset; + min-width: 100vw; + min-height: 100vh; + background-color: #2121214f; +} + +.navbar-overlay-backdrop { + flex: 1; +} + +/* .left-navbar-mobile dialog .dialog-container { + display: flex; + flex +} */ + +.left-navbar-mobile-overlay { + width: 65vw; + min-height: 100vh; +} + +.navbar-mobile-btn { + margin: 0.3em; +} diff --git a/src/components/navbar.tsx b/src/components/navbar.tsx index 837c6b6..33f164b 100644 --- a/src/components/navbar.tsx +++ b/src/components/navbar.tsx @@ -30,6 +30,125 @@ const NavbarLink = (props: { href: string; label: string; isActive?: boolean }) ); }; +const NavbarAllLinks = (props: { activePage?: string }) => { + return ( + <> + + + + + + + + + + + + + + + + + + ); +}; + +const LeftNavbarDesktop = (props: { activePage?: string }) => { + return ( +
+ + + +
+ +
+
+ ); +}; + +const LeftNavbarMobile = (props: { activePage?: string }) => { + return ( +
+ + +
+
+ + + +
+ +
+
+ +
+
+
+ ); +}; + export const Navbar = (props: { activePage?: string }) => { return (
@@ -37,92 +156,11 @@ export const Navbar = (props: { activePage?: string }) => { dirname={__dirname} path="./navbar.css" /> -
- - - -
- - - - - - - - - - - - - - - - -
-
+ +