www: update docs design (#1423)
This commit is contained in:
@@ -52,7 +52,7 @@ export default function DocsSidebar(
|
||||
</span>
|
||||
</button>
|
||||
)
|
||||
: <SearchButton />}
|
||||
: <SearchButton class="lg:hidden" />}
|
||||
|
||||
<div class="mb-4">
|
||||
<VersionSelect
|
||||
@@ -61,7 +61,7 @@ export default function DocsSidebar(
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ol class="list-decimal list-inside font-semibold nested">
|
||||
<ol class="list-decimal list-inside font-semibold nested ml-2.5">
|
||||
{CATEGORIES[props.selectedVersion].map((category) => (
|
||||
<SidebarCategory path={props.path} category={category} />
|
||||
))}
|
||||
@@ -71,7 +71,7 @@ export default function DocsSidebar(
|
||||
}
|
||||
|
||||
const link = "text(gray-900 hover:gray-600)";
|
||||
const linkActive = "text(green-600 hover:green-500)";
|
||||
const linkActive = "text(green-600 hover:green-500) font-bold";
|
||||
|
||||
export function SidebarCategory(props: {
|
||||
path: string;
|
||||
@@ -83,9 +83,11 @@ export function SidebarCategory(props: {
|
||||
|
||||
return (
|
||||
<li class="my-2 block">
|
||||
<a href={href} class={outerLink}>{title}</a>
|
||||
<a href={href} class={outerLink}>
|
||||
{title}
|
||||
</a>
|
||||
{entries.length > 0 && (
|
||||
<ol class="pl-4 list-decimal nested">
|
||||
<ol class="pb-2 pl-4 list-decimal nested list-outside">
|
||||
{entries.map((entry) => (
|
||||
<SidebarEntry path={props.path} entry={entry} />
|
||||
))}
|
||||
@@ -101,10 +103,12 @@ export function SidebarEntry(props: {
|
||||
}) {
|
||||
const { title, href } = props.entry;
|
||||
|
||||
const innerLink = `${href == props.path ? linkActive : link} font-normal`;
|
||||
const innerLink = `${
|
||||
href == props.path ? linkActive : link
|
||||
} transition-colors hover:text-green-500 font-normal`;
|
||||
|
||||
return (
|
||||
<li class="my-0.5">
|
||||
<li class="py-0.5">
|
||||
<a href={href} class={innerLink}>{title}</a>
|
||||
</li>
|
||||
);
|
||||
|
||||
+11
-14
@@ -1,21 +1,23 @@
|
||||
import DocsTitle from "./DocsTitle.tsx";
|
||||
import NavigationBar from "./NavigationBar.tsx";
|
||||
import SearchButton from "../islands/SearchButton.tsx";
|
||||
|
||||
export default function Header(props: { title: string; active: string }) {
|
||||
const isHome = props.active == "/";
|
||||
const isDocs = props.active.startsWith("/docs");
|
||||
return (
|
||||
<div>
|
||||
<header
|
||||
class={"mx-auto max-w-screen-lg flex gap-3 " +
|
||||
class={"mx-auto max-w-screen-xl flex gap-3 items-center " +
|
||||
(isHome ? "justify-end" : "justify-between")}
|
||||
>
|
||||
{!isHome &&
|
||||
(
|
||||
<div class="p-4 flex items-center">
|
||||
<Logo />
|
||||
<DocsTitle title={props.title} />
|
||||
</div>
|
||||
)}
|
||||
{!isHome && (
|
||||
<div class="p-4 flex items-center">
|
||||
<Logo />
|
||||
<DocsTitle title={props.title} />
|
||||
</div>
|
||||
)}
|
||||
{isDocs && <SearchButton class="grow mb-0 hidden lg:flex" />}
|
||||
<NavigationBar class="hidden md:flex" active={props.active} />
|
||||
</header>
|
||||
<NavigationBar class="md:hidden pb-3" active={props.active} />
|
||||
@@ -26,12 +28,7 @@ export default function Header(props: { title: string; active: string }) {
|
||||
function Logo() {
|
||||
return (
|
||||
<a href="/" class="flex mr-3 items-center" aria-label="Top Page">
|
||||
<img
|
||||
src="/logo.svg"
|
||||
alt="Fresh logo"
|
||||
width={40}
|
||||
height={40}
|
||||
/>
|
||||
<img src="/logo.svg" alt="Fresh logo" width={40} height={40} />
|
||||
</a>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Head } from "$fresh/runtime.ts";
|
||||
import { useEffect, useRef } from "preact/hooks";
|
||||
import docsearch from "https://esm.sh/@docsearch/js@3";
|
||||
|
||||
export default function SearchButton() {
|
||||
export default function SearchButton(props: { class?: string }) {
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
useEffect(() => {
|
||||
if (ref.current) {
|
||||
@@ -22,7 +22,7 @@ export default function SearchButton() {
|
||||
href="/docsearch.css"
|
||||
/>
|
||||
</Head>
|
||||
<div class="h-9 mb-6" ref={ref}></div>
|
||||
<div class={"h-9 mb-6 " + (props.class ?? "")} ref={ref}></div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -168,7 +168,7 @@ function Main(props: { path: string; page: Page }) {
|
||||
return (
|
||||
<div class="flex-1">
|
||||
<MobileSidebar path={props.path} page={props.page} />
|
||||
<div class="flex mx-auto max-w-screen-lg px-4 py-5 justify-end">
|
||||
<div class="flex mx-auto max-w-screen-xl px-4 md:px-0 py-5 md:py-0 justify-end">
|
||||
<label
|
||||
for="docs_sidebar"
|
||||
class="px-4 py-3 md:hidden flex items-center hover:bg-gray-100 rounded gap-2"
|
||||
@@ -187,12 +187,10 @@ function Main(props: { path: string; page: Page }) {
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
<div>
|
||||
Menu
|
||||
</div>
|
||||
<div>Menu</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="mx-auto max-w-screen-lg px-4 flex gap-6">
|
||||
<div class="mx-auto max-w-screen-xl px-4 flex gap-6 md:gap-8">
|
||||
<DesktopSidebar path={props.path} page={props.page} />
|
||||
<Content page={props.page} />
|
||||
</div>
|
||||
@@ -235,7 +233,7 @@ function MobileSidebar(props: { path: string; page: Page }) {
|
||||
|
||||
function DesktopSidebar(props: { path: string; page: Page }) {
|
||||
return (
|
||||
<nav class="w-[16rem] flex-shrink-0 hidden md:block py-8 pr-4 border(r-2 gray-100)">
|
||||
<nav class="w-[18rem] flex-shrink-0 hidden md:block py-7 pr-8">
|
||||
<DocsSidebar
|
||||
path={props.path}
|
||||
versionLinks={props.page.versionLinks}
|
||||
@@ -248,8 +246,8 @@ function DesktopSidebar(props: { path: string; page: Page }) {
|
||||
function Content(props: { page: Page }) {
|
||||
const html = gfm.render(props.page.markdown);
|
||||
return (
|
||||
<main class="py-6 overflow-hidden">
|
||||
<h1 class="text(4xl gray-900) tracking-tight font-extrabold mt-6">
|
||||
<main class="py-6 overflow-hidden md:mr-4 lg:mr-32">
|
||||
<h1 class="text(4xl gray-900) tracking-tight font-extrabold mt-6 md:mt-0">
|
||||
{props.page.title}
|
||||
</h1>
|
||||
<div
|
||||
@@ -268,14 +266,12 @@ function Content(props: { page: Page }) {
|
||||
|
||||
const button = "p-2 bg-gray-100 w-full border(1 gray-200) grid";
|
||||
|
||||
function ForwardBackButtons(
|
||||
props: {
|
||||
slug: string;
|
||||
version: string;
|
||||
prev?: NavEntry;
|
||||
next?: NavEntry;
|
||||
},
|
||||
) {
|
||||
function ForwardBackButtons(props: {
|
||||
slug: string;
|
||||
version: string;
|
||||
prev?: NavEntry;
|
||||
next?: NavEntry;
|
||||
}) {
|
||||
const { prev, next } = props;
|
||||
const upper = "text(sm gray-600)";
|
||||
const category = "font-normal";
|
||||
|
||||
@@ -31,6 +31,11 @@ ol.nested li:before {
|
||||
list-style: numeric;
|
||||
}
|
||||
|
||||
.markdown-body .highlight {
|
||||
border: 1px solid #eaeef1;
|
||||
border-radius: .5rem;
|
||||
}
|
||||
|
||||
.toggle:checked + .toggled {
|
||||
display: block;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
.DocSearch-Button{
|
||||
margin:0;
|
||||
width: 100%;
|
||||
border-radius: 0.5rem;
|
||||
}
|
||||
.DocSearch-Button-Placeholder {
|
||||
display: initial;
|
||||
|
||||
@@ -43,5 +43,10 @@ export default {
|
||||
"background-repeat": "no-repeat",
|
||||
};
|
||||
},
|
||||
"grow": () => {
|
||||
return {
|
||||
"flex-grow": "1",
|
||||
};
|
||||
},
|
||||
},
|
||||
} as Options;
|
||||
|
||||
Reference in New Issue
Block a user