Skip to content

Commit 664fb4c

Browse files
Move docs.css to docs-layout.tsx (#173)
* Move docs css to `docs-layout.tsx` * Add prefetch="intent" to links on splash page * format * Refactor docs layout structure and CSS placement
1 parent 48ecb19 commit 664fb4c

File tree

3 files changed

+33
-29
lines changed

3 files changed

+33
-29
lines changed

app/pages/docs-layout.tsx

Lines changed: 31 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import semver from "semver";
1313
import { useRef } from "react";
1414
import { useCodeBlockCopyButton } from "~/ui/utils";
1515

16+
import docsCss from "~/styles/docs.css?url";
17+
1618
export let loader = async ({ params }: Route.LoaderArgs) => {
1719
let splat = params["*"];
1820
let firstSegment = splat?.split("/")[0];
@@ -41,35 +43,38 @@ export default function DocsLayout({ loaderData }: Route.ComponentProps) {
4143
useCodeBlockCopyButton(docsContainer);
4244

4345
return (
44-
<div className="[--header-height:theme(spacing.16)] [--nav-width:theme(spacing.72)] lg:m-auto lg:max-w-[90rem]">
45-
<div className="sticky top-0 z-20">
46-
<Header />
47-
<NavMenuMobile>
48-
<Menu menu={menu} />
49-
</NavMenuMobile>
50-
</div>
46+
<>
47+
<link rel="stylesheet" href={docsCss} />
48+
<div className="[--header-height:theme(spacing.16)] [--nav-width:theme(spacing.72)] lg:m-auto lg:max-w-[90rem]">
49+
<div className="sticky top-0 z-20">
50+
<Header />
51+
<NavMenuMobile>
52+
<Menu menu={menu} />
53+
</NavMenuMobile>
54+
</div>
5155

52-
<div className="block lg:flex">
53-
<NavMenuDesktop>
54-
<Menu menu={menu} />
55-
</NavMenuDesktop>
56-
<div
57-
ref={docsContainer}
58-
className={classNames(
59-
// add scroll margin to focused elements so that they aren't
60-
// obscured by the sticky header
61-
"[&_*:focus]:scroll-mt-[8rem] lg:[&_*:focus]:scroll-mt-[5rem]",
62-
// Account for the left navbar
63-
"min-h-[80vh] lg:ml-3 lg:w-[calc(100%-var(--nav-width))]",
64-
"flex flex-col lg:pl-6 xl:pl-10 2xl:pl-12",
65-
)}
66-
>
67-
<Outlet />
68-
<div className="mt-auto px-4 pt-8 lg:pr-8 xl:pl-0">
69-
<Footer />
56+
<div className="block lg:flex">
57+
<NavMenuDesktop>
58+
<Menu menu={menu} />
59+
</NavMenuDesktop>
60+
<div
61+
ref={docsContainer}
62+
className={classNames(
63+
// add scroll margin to focused elements so that they aren't
64+
// obscured by the sticky header
65+
"[&_*:focus]:scroll-mt-[8rem] lg:[&_*:focus]:scroll-mt-[5rem]",
66+
// Account for the left navbar
67+
"min-h-[80vh] lg:ml-3 lg:w-[calc(100%-var(--nav-width))]",
68+
"flex flex-col lg:pl-6 xl:pl-10 2xl:pl-12",
69+
)}
70+
>
71+
<Outlet />
72+
<div className="mt-auto px-4 pt-8 lg:pr-8 xl:pl-0">
73+
<Footer />
74+
</div>
7075
</div>
7176
</div>
7277
</div>
73-
</div>
78+
</>
7479
);
7580
}

app/pages/splash.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,7 @@ export default function Home({ loaderData }: Route.ComponentProps) {
135135
<Link
136136
key={title}
137137
to={to}
138+
prefetch="intent"
138139
className={
139140
"flex gap-x-2 border border-gray-200 px-9 py-6 text-gray-700 hover:bg-gray-50 dark:border-gray-700 dark:text-gray-200 dark:hover:text-gray-700" +
140141
(i === 0
@@ -190,6 +191,7 @@ export default function Home({ loaderData }: Route.ComponentProps) {
190191
<Link
191192
key={title}
192193
to={linkTo}
194+
prefetch="intent"
193195
className="flex flex-col justify-between gap-y-6 rounded-lg border border-[#D9D9D9] p-8 hover:bg-gray-50 dark:border-gray-700 dark:hover:bg-gray-700"
194196
>
195197
<div className="flex flex-col gap-y-4">

app/root.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,6 @@ import { DocSearch } from "./modules/docsearch";
2121
import "~/styles/tailwind.css";
2222
import "@docsearch/css/dist/style.css";
2323
import "~/styles/docsearch.css";
24-
// FIXUP: Styles need to all be imported in root until this is fixed:
25-
// https://github.com/remix-run/react-router/issues/12382
26-
import "~/styles/docs.css";
2724
import type { Route } from "./+types/root";
2825

2926
export async function loader({ request }: LoaderFunctionArgs) {

0 commit comments

Comments
 (0)