Skip to content

Commit

Permalink
Revert "adding header links to sidebar on mobile (#1211)"
Browse files Browse the repository at this point in the history
This reverts commit 0e12b28.
  • Loading branch information
thisisjofrank authored Dec 12, 2024
1 parent 0e12b28 commit 10c9aee
Show file tree
Hide file tree
Showing 11 changed files with 84 additions and 150 deletions.
79 changes: 9 additions & 70 deletions _components/Sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,43 +17,15 @@ export default function Sidebar(
) {
return (
<nav
class="overflow-y-auto overflow-x-hidden"
class="p-2 pt-0 pr-0 overflow-y-auto overflow-x-hidden"
style={{ scrollbarGutter: "stable", scrollbarWidth: "thin" }}
>
<ul className="xl:hidden border-bg-tertiary relative bg-background-secondary m-2 mt-0 mb-4 py-2 rounded-md border border-background-tertiary">
<SidebarTopNav
name="Runtime"
url="/runtime/"
currentPath={props.url}
/>
<SidebarTopNav
name="API reference"
url="/api/deno/"
currentPath={props.url}
/>
<SidebarTopNav
name="Examples"
url="/examples/"
currentPath={props.url}
/>
<SidebarTopNav
name="Deploy"
url="/deploy/"
currentPath={props.url}
/>
<SidebarTopNav
name="Subhosting"
url="/subhosting/"
currentPath={props.url}
/>
</ul>
<ul>
{props.sidebar.map((section, idx) => (
{props.sidebar.map((section) => (
<SidebarSection
section={section}
search={props.search}
url={props.url}
headerPath={props.headerPath}
/>
))}
</ul>
Expand All @@ -73,8 +45,8 @@ function SidebarSection(
str.replaceAll(/[\s_]/g, "-")
.replaceAll(/[^a-zA-Z0-9-]/g, "")
.toLowerCase();
const slug = "-" + slugify(props.section.title ?? "");
const categoryTitle = `sidebar-category${slug}`;
const slug = slugify(props.section.title ?? "");
const categoryTitle = `sidebar-category-${slug}`;
const headingLink = props.section.href;

return (
Expand All @@ -85,7 +57,7 @@ function SidebarSection(
<a href={headingLink}>
<h2
id={categoryTitle}
class="border-b border-foreground-tertiary pt-2 pb-1.5 -mx-5 px-8 mb-2 text-sm font-semibold hover:bg-background-secondary current:bg-background-secondary current:text-blue-500 text-foreground-primary capitalize"
class="border-b border-foreground-tertiary pt-2 pb-1.5 -mx-5 px-8 mt-4 mb-2 text-sm font-semibold hover:bg-background-secondary current:bg-background-secondary current:text-blue-500 text-foreground-primary capitalize"
aria-current={props.url === headingLink ? "page" : undefined}
>
{props.section.title}
Expand All @@ -95,13 +67,13 @@ function SidebarSection(
: (
<h2
id={categoryTitle}
class="border-b border-foreground-tertiary pt-2 pb-0.5 -mx-5 px-8 mb-3 text-sm font-semibold text-foreground-primary capitalize"
class="border-b border-foreground-tertiary pt-2 pb-0.5 -mx-5 px-8 mt-4 mb-3 text-sm font-semibold text-foreground-primary capitalize"
>
{props.section.title}
</h2>
)
)}{" "}
<ul aria-labelledby={categoryTitle} class="mb-4">
<ul aria-labelledby={categoryTitle}>
{props.section.items.map((item) => (
<li class="mx-2">
{typeof item === "object" && "items" in item
Expand Down Expand Up @@ -173,7 +145,7 @@ function SidebarCategory(props: {
if (typeof item === "string") {
return item === props.url;
}
return typeof item === "object" && "id" in item && item.id === props.url;
return item.id === props.url;
});

return (
Expand Down Expand Up @@ -204,42 +176,9 @@ function SidebarCategory(props: {
data-accordion-content
>
{props.item.items.map((item) => (
typeof item === "object" && "items" in item
? (
<SidebarCategory
item={item}
url={props.url}
search={props.search}
/>
)
: (
<SidebarItem
item={item}
search={props.search}
url={props.url}
/>
)
<SidebarItem item={item} search={props.search} url={props.url} />
))}
</ul>
</>
);
}

function SidebarTopNav(
props: { name: string; url: string; currentPath: string },
) {
const isCurrentlyActivePath = props.currentPath.startsWith(props.url);
return (
<li class="mx-2">
<a
class={`relative block py-1.5 px-1.5 text-base text-foreground-primary leading-snug rounded ring-1 ring-transparent hover:ring-background-tertiary hover:bg-background-secondary transition-colors duration-200 ease-in-out select-none current:bg-background-tertiary ${
isCurrentlyActivePath ? "font-semibold" : "font-normal"
}`}
href={props.url}
aria-current={isCurrentlyActivePath ? "page" : undefined}
>
{props.name}
</a>
</li>
);
}
9 changes: 0 additions & 9 deletions _components/ToTop.tsx

This file was deleted.

10 changes: 5 additions & 5 deletions _includes/doc.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Breadcrumbs } from "../_components/Breadcrumbs.tsx";
import Logo from "../_components/Logo.tsx";
import { NavigationButton } from "../_components/NavigationButton.tsx";
import { TableOfContentsItem } from "../_components/TableOfContentsItem.tsx";
import { TableOfContentsItemMobile } from "../_components/TableOfContentsItemMobile.tsx";
import {
Sidebar as Sidebar_,
SidebarItem,
TableOfContentsItem as TableOfContentsItem_,
} from "../types.ts";
import { Breadcrumbs } from "../_components/Breadcrumbs.tsx";
import { NavigationButton } from "../_components/NavigationButton.tsx";
import { TableOfContentsItem } from "../_components/TableOfContentsItem.tsx";
import { TableOfContentsItemMobile } from "../_components/TableOfContentsItemMobile.tsx";
import renderCommand from "./renderCommand.tsx";

export const layout = "layout.tsx";
Expand Down Expand Up @@ -73,7 +73,7 @@ export default function Page(props: Lume.Data, helpers: Lume.Helpers) {
id="sidebar"
data-open="false"
>
<div class="xl:hidden p-4 flex justify-between h-16">
<div class="xl:hidden p-4 shadow-sm flex justify-between h-16">
<a class="flex items-center gap-3 mr-6" href="/">
<Logo />
</a>
Expand Down
24 changes: 20 additions & 4 deletions _includes/raw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ export const layout = "layout.tsx";
export default function Raw(props: Lume.Data, helpers: Lume.Helpers) {
const reference = props.url.startsWith("/api");

if (reference) {
return (
<div>
{props.children}
</div>
);
}

return (
<>
{props.sidebar && (
Expand All @@ -12,7 +20,7 @@ export default function Raw(props: Lume.Data, helpers: Lume.Helpers) {
id="sidebar"
data-open="false"
>
<div class="p-4 flex justify-between h-16">
<div class="p-4 shadow-sm flex justify-between h-16">
<a class="flex items-center gap-3 mr-6" href="/">
<img
src="/img/logo.svg"
Expand Down Expand Up @@ -47,12 +55,20 @@ export default function Raw(props: Lume.Data, helpers: Lume.Helpers) {
url={props.url}
/>
</aside>
<div
class="absolute inset-0 backdrop-brightness-50 z-40 hidden sidebar-open:block sidebar-open:xl:hidden"
id="sidebar-cover"
data-open="false"
>
</div>
</>
)}
<div style={{ scrollbarGutter: "stable" }}>
<div
class="absolute top-16 bottom-0 left-0 right-0 overflow-y-auto"
style={{ scrollbarGutter: "stable" }}
>
{props.children}
{reference && <props.comp.ToTop />}
{!reference && <props.comp.Footer />}
<props.comp.Footer />
</div>
</>
);
Expand Down
4 changes: 1 addition & 3 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,8 @@
"tailwindcss": "npm:tailwindcss@^3.4.9"
},
"tasks": {
"serve": "deno run -A lume.ts -s",
"start": "deno task serve",
"dev": "deno task serve",
"build": "deno run -A lume.ts",
"serve": "deno run -A lume.ts -s",
"debug": "deno task build && deno task prod",
"prod": "cd _site && deno run --allow-read --allow-env --allow-net server.ts",
"reference": "cd reference_gen && deno task types && deno task doc",
Expand Down
27 changes: 26 additions & 1 deletion examples/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
export const layout = "raw.tsx";
export const sidebar = [];
export const sidebar = [
{
items: [
{
label: "Runtime",
id: "/runtime/",
},
{
label: "API Reference",
id: "/api/deno/",
},
{
label: "Examples",
id: "/examples/",
},
{
label: "Deploy",
id: "/deploy/",
},
{
label: "Subhosting",
id: "/subhosting/",
},
],
},
];

export const toc = [];

Expand Down
20 changes: 20 additions & 0 deletions index.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ export const url = "/";
export const sidebar = [
{
items: [
{
label: "Runtime Manual",
id: "/runtime/",
},
{
label: "API reference",
id: "/api/deno",
},
{
label: "Examples",
id: "/examples/",
},
{
label: "Deploy",
id: "/deploy/manual/",
},
{
label: "Subhosting",
id: "/subhosting/manual/",
},
{
label: "deno.com",
id: "https://deno.com",
Expand Down
36 changes: 3 additions & 33 deletions overrides.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* This file exists to provide CSS overrides to styles that exist on the pages
/* This file exists to provide CSS overrides to styles that exist on the pages
that are generated by deno_doc, the tool that powers the API reference documentation */

#content > main > section + div {
Expand Down Expand Up @@ -63,8 +63,8 @@ that are generated by deno_doc, the tool that powers the API reference documenta
@apply ml-1 !important;
}

.ddoc .z-50 {
z-index: 49 !important;
.doc .toc :not(.documentNavigation) > a {
@apply text-xl !important;
}

.ddoc .usageContent {
Expand Down Expand Up @@ -115,33 +115,3 @@ that are generated by deno_doc, the tool that powers the API reference documenta
.ddoc .space-y-7 > .section .markdown-body {
@apply mb-6 !important;
}

.totop {
@apply block fixed p-3 bg-background-secondary rounded-md border
border-background-tertiary bottom-4 right-4 text-transparent;
animation-name: showToTop;
animation-duration: 1ms;
animation-timeline: --showScrollTop;
}

.totop::after {
@apply block w-4 h-4 border-2 border-primary border-l-0 border-t-0;
content: "";
transform: translate(0, 25%) rotate(225deg);
}

html {
scroll-timeline: --showScrollTop y;
scroll-timeline: --showScrollTop vertical;
}

@keyframes showToTop {
0% {
opacity: 0;
transform: translateY(300%);
}
10% {
opacity: 1;
transform: translateY(0%);
}
}
19 changes: 0 additions & 19 deletions reference.page.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ import entityList from "@std/html/named-entity-list.json" with { type: "json" };

export const layout = "raw.tsx";

export const sidebar = [
{
items: [
{
label: "Deno APIs",
id: "/api/deno/",
},
{
label: "Web APIs",
id: "/api/web/",
},
{
label: "Node APIs",
id: "/api/node/",
},
],
},
];

const resetRegexp =
/<link id="ddocResetStylesheet" rel="stylesheet" href=".*?reset\.css">\s*/;
const titleRegexp = /<title>(.+?)<\/title>\s*/s;
Expand Down
2 changes: 0 additions & 2 deletions sidebar.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ for (const el of document.querySelectorAll("[data-accordion-trigger]")) {
}

const sidebar = document.getElementById("sidebar");
console.log(sidebar);

if (sidebar) {
const sidebarNav = sidebar.querySelector("nav")!;
const sidebarOpen = document.getElementById("sidebar-open");
Expand Down
4 changes: 0 additions & 4 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@
}
}

html {
scroll-behavior: smooth;
}

/* Scrollbar colors that look good on light and dark theme */
* {
scrollbar-color: hsla(0deg, 0%, 50%, 0.5) hsla(0deg, 0%, 50%, 0.1) !important;
Expand Down

0 comments on commit 10c9aee

Please sign in to comment.