more docks mockuping

This commit is contained in:
MapleLeaf
2022-01-14 15:54:10 -06:00
parent 723d663d3c
commit d6e2f083bc
3 changed files with 60 additions and 23 deletions

View File

@@ -1,8 +1,8 @@
import type { JSONOutput } from "typedoc" import type { JSONOutput } from "typedoc"
import apiData from "~/assets/api.json"
export type ApiData = JSONOutput.ContainerReflection export type ApiData = JSONOutput.ContainerReflection
export async function loadApiData(): Promise<ApiData> { export function getApiData(): ApiData {
const data = await import("~/assets/api.json") return apiData as ApiData
return data as ApiData
} }

View File

@@ -2,16 +2,12 @@ import clsx from "clsx"
import { Fragment } from "react" import { Fragment } from "react"
import type { LoaderFunction } from "remix" import type { LoaderFunction } from "remix"
import { Outlet, useLoaderData } from "remix" import { Outlet, useLoaderData } from "remix"
import { loadApiData } from "~/modules/api/api-data.server" import { getApiData } from "~/modules/api/api-data.server"
import { ActiveLink } from "~/modules/navigation/active-link" import { ActiveLink } from "~/modules/navigation/active-link"
import type { AppLinkProps } from "~/modules/navigation/app-link" import type { AppLinkProps } from "~/modules/navigation/app-link"
import { AppLink } from "~/modules/navigation/app-link" import { AppLink } from "~/modules/navigation/app-link"
import { MainNavigation } from "~/modules/navigation/main-navigation" import { MainNavigation } from "~/modules/navigation/main-navigation"
import { import { linkClass, maxWidthContainer } from "~/modules/ui/components"
docsProseClass,
linkClass,
maxWidthContainer,
} from "~/modules/ui/components"
type LoaderData = { type LoaderData = {
categorySections: Array<{ categorySections: Array<{
@@ -22,7 +18,7 @@ type LoaderData = {
} }
export const loader: LoaderFunction = async () => { export const loader: LoaderFunction = async () => {
const apiData = await loadApiData() const apiData = getApiData()
const childrenById = Object.fromEntries( const childrenById = Object.fromEntries(
apiData.children.map((child) => [child.id, { name: child.name }]), apiData.children.map((child) => [child.id, { name: child.name }]),
@@ -73,7 +69,7 @@ export default function ApiReferencePage() {
))} ))}
</nav> </nav>
<main className={clsx(docsProseClass, "pb-8 flex-1 min-w-0")}> <main className="pb-8 flex-1 min-w-0">
<Outlet /> <Outlet />
</main> </main>
</div> </div>

View File

@@ -1,21 +1,21 @@
import type { LoaderFunction } from "remix" import type { LoaderFunction } from "remix"
import { useLoaderData } from "remix" import { useLoaderData } from "remix"
import { inspect } from "node:util" import { getApiData } from "~/modules/api/api-data.server"
import { loadApiData } from "~/modules/api/api-data.server"
import { renderMarkdown } from "~/modules/markdown/render-markdown.server" import { renderMarkdown } from "~/modules/markdown/render-markdown.server"
import { docsProseClass } from "~/modules/ui/components"
type LoaderData = { type LoaderData = {
title: string title: string
description?: { __html: string } description?: { __html: string }
[key: string]: unknown
} }
export const loader: LoaderFunction = async ({ params }) => { export const loader: LoaderFunction = async ({ params }) => {
const apiData = await loadApiData() const apiData = getApiData()
const entityName = params.name! const entityName = params.name!
const info = apiData.children?.find((child) => child.name === entityName) const info = apiData.children?.find((child) => child.name === entityName)
console.log(inspect(info, { depth: Number.POSITIVE_INFINITY }))
const description = [ const description = [
info?.comment?.shortText, info?.comment?.shortText,
@@ -29,6 +29,11 @@ export const loader: LoaderFunction = async ({ params }) => {
const data: LoaderData = { const data: LoaderData = {
title: entityName, title: entityName,
description: description ? await renderMarkdown(description) : undefined, description: description ? await renderMarkdown(description) : undefined,
sig: await renderMarkdown(`
\`\`\`tsx
function ActionRow(props: ActionRowProps): ReactElement
\`\`\`
`),
} }
return data return data
} }
@@ -38,14 +43,50 @@ export default function ApiDetailPage() {
return ( return (
<> <>
<h1>{data.title}</h1> <h1 className="text-3xl font-light">{data.title}</h1>
{data.description ? ( <p className="text-sm font-bold opacity-50 uppercase mt-1">Component</p>
<section dangerouslySetInnerHTML={data.description} /> <section
) : undefined} className={docsProseClass}
dangerouslySetInnerHTML={data.description}
/>
<section className={docsProseClass}>
<ul>
<li>
<p>
<code>children?: ReactNode</code>
</p>
<p>
This should be a list of <code>{`<Option />`}</code> components.
</p>
<ul>
<li>
<p>
<code>disabled?: boolean</code>
</p>
<p>
When true, the select will be slightly faded, and cannot be
interacted with.
</p>
</li>
</ul>
</li>
<li>
<p>
<code>minValues?: number</code>
</p>
<p>
With <code>multiple</code>, the minimum number of values that can
be selected. When <code>multiple</code> is false or not defined,
this is always 1.
</p>
<p>
This only limits the number of values that can be received by the
user. This does not limit the number of values that can be
displayed by you.
</p>
</li>
</ul>
</section>
</> </>
) )
} }
function addDefined<Value extends number | string>(
...values: Array<Value | undefined>
): Value | undefined {}