docs: Enhanced CSR Layout (#1908)
Co-authored-by: Marvin Hagemeister <marvin@deno.com>
This commit is contained in:
co-authored by
Marvin Hagemeister
parent
7d954584a6
commit
eb41b65d4c
@@ -155,10 +155,8 @@ export default function DocsPage(props: PageProps<Data>) {
|
||||
<meta property="og:image" content={ogImageUrl} />
|
||||
<meta name="view-transition" content="same-origin" />
|
||||
</Head>
|
||||
<div class="flex flex-col min-h-screen">
|
||||
<Header title="docs" active="/docs" />
|
||||
<div class="flex flex-col min-h-screen mx-auto max-w-screen-xl">
|
||||
<Main page={props.data.page} />
|
||||
<Footer />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
@@ -166,31 +164,8 @@ export default function DocsPage(props: PageProps<Data>) {
|
||||
|
||||
function Main(props: { page: Page }) {
|
||||
return (
|
||||
<div class="flex-1" f-client-nav>
|
||||
<MobileSidebar page={props.page} />
|
||||
<div class="flex mx-auto max-w-screen-xl px-4 md:px-0 md:py-0 justify-end bg-gray-100">
|
||||
<label
|
||||
for="docs_sidebar"
|
||||
class="px-4 py-3 md:hidden flex items-center hover:bg-gray-100 rounded gap-2 cursor-pointer"
|
||||
>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M4 6h16M4 12h16M4 18h7"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
<div>Table of Contents</div>
|
||||
</label>
|
||||
</div>
|
||||
<div class="mx-auto max-w-screen-xl flex gap-6 md:gap-8">
|
||||
<div class="flex-1 " f-client-nav>
|
||||
<div class=" md:flex">
|
||||
<DesktopSidebar page={props.page} />
|
||||
<Partial name="docs-main">
|
||||
<Content page={props.page} />
|
||||
@@ -202,7 +177,7 @@ function Main(props: { page: Page }) {
|
||||
|
||||
function MobileSidebar(props: { page: Page }) {
|
||||
return (
|
||||
<>
|
||||
<div class="md:hidden">
|
||||
<input
|
||||
type="checkbox"
|
||||
class="hidden toggle"
|
||||
@@ -215,11 +190,8 @@ function MobileSidebar(props: { page: Page }) {
|
||||
class="absolute inset-0 bg-gray-600 opacity-75"
|
||||
for="docs_sidebar"
|
||||
/>
|
||||
<div class="relative flex-1 flex flex-col w-[16rem] h-full bg-white border(r-2 gray-100)">
|
||||
<div class="p-4 border(b-2 gray-100) bg-green-300">
|
||||
<DocsTitle title="docs" />
|
||||
</div>
|
||||
<nav class="pt-6 pb-16 px-4 overflow-x-auto">
|
||||
<div class="relative flex-1 flex flex-col w-[18rem] h-full bg-white border(r-2 gray-100)">
|
||||
<nav class="pt-0 pb-16 px-4 overflow-x-auto">
|
||||
<DocsSidebar
|
||||
mobile
|
||||
versionLinks={props.page.versionLinks}
|
||||
@@ -228,13 +200,13 @@ function MobileSidebar(props: { page: Page }) {
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function DesktopSidebar(props: { page: Page }) {
|
||||
return (
|
||||
<nav class="w-[18rem] flex-shrink-0 hidden md:block py-7 px-4">
|
||||
<nav class="w-[18rem] flex-shrink-0 hidden md:block px-4">
|
||||
<DocsSidebar
|
||||
versionLinks={props.page.versionLinks}
|
||||
selectedVersion={props.page.version}
|
||||
@@ -246,21 +218,48 @@ function DesktopSidebar(props: { page: Page }) {
|
||||
function Content(props: { page: Page }) {
|
||||
const html = renderMarkdown(props.page.markdown);
|
||||
return (
|
||||
<main class="py-6 md:mr-4 lg:mr-32 min-w-0">
|
||||
<h1 class="text(4xl gray-900) tracking-tight font-extrabold md:mt-0 px-4">
|
||||
{props.page.title}
|
||||
</h1>
|
||||
<div
|
||||
class="mt-6 markdown-body"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
<ForwardBackButtons
|
||||
slug={props.page.slug}
|
||||
version={props.page.version}
|
||||
prev={props.page.prevNav}
|
||||
next={props.page.nextNav}
|
||||
/>
|
||||
</main>
|
||||
<div class="w-full min-w-0">
|
||||
<Header title="docs" active="/docs" />
|
||||
<main class="max-w-3xl mt-4 min-w-0 mx-auto">
|
||||
<MobileSidebar page={props.page} />
|
||||
<div class="flex mx-auto max-w-screen-xl px-4 md:px-0 md:py-0 justify-end bg-gray-100">
|
||||
<label
|
||||
for="docs_sidebar"
|
||||
class="px-4 py-3 md:hidden flex items-center hover:bg-gray-100 rounded gap-2 cursor-pointer"
|
||||
>
|
||||
<svg
|
||||
class="h-6 w-6"
|
||||
stroke="currentColor"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
strokeWidth="2"
|
||||
d="M4 6h16M4 12h16M4 18h7"
|
||||
>
|
||||
</path>
|
||||
</svg>
|
||||
<div>Table of Contents</div>
|
||||
</label>
|
||||
</div>
|
||||
<h1 class="text(4xl gray-900) tracking-tight font-extrabold md:mt-0 px-4">
|
||||
{props.page.title}
|
||||
</h1>
|
||||
<div
|
||||
class="mt-6 markdown-body"
|
||||
dangerouslySetInnerHTML={{ __html: html }}
|
||||
/>
|
||||
<ForwardBackButtons
|
||||
slug={props.page.slug}
|
||||
version={props.page.version}
|
||||
prev={props.page.prevNav}
|
||||
next={props.page.nextNav}
|
||||
/>
|
||||
<Footer />
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user