cloudflare/kumo
Publicmirrored fromhttps://github.com/cloudflare/kumoAvailable
packages/kumo-docs-astro/src/layouts/DocLayout.astro
102lines · modecode
| 1 | --- |
| 2 | import MainLayout from "./MainLayout.astro"; |
| 3 | import { StickyDocHeader } from "../components/docs/StickyDocHeader"; |
| 4 | import { BaseUIIcon } from "../components/docs/icons/BaseUIIcon"; |
| 5 | import { GithubLogo } from "@phosphor-icons/react"; |
| 6 | |
| 7 | interface Props { |
| 8 | title: string; |
| 9 | description: string; |
| 10 | baseUIComponent?: string; |
| 11 | /** Path to the source file in the kumo package (e.g., "components/button") - will link to GitHub */ |
| 12 | sourceFile?: string; |
| 13 | } |
| 14 | |
| 15 | const { title, description, baseUIComponent, sourceFile } = |
| 16 | Astro.props; |
| 17 | |
| 18 | const baseUIUrl = baseUIComponent |
| 19 | ? `https://base-ui.com/react/components/${baseUIComponent}` |
| 20 | : null; |
| 21 | |
| 22 | // Extract the component name from the path (e.g., "components/button" -> "button") |
| 23 | // and construct the direct file URL (e.g., "components/button/button.tsx") |
| 24 | const githubSourceUrl = sourceFile |
| 25 | ? (() => { |
| 26 | const componentName = sourceFile.split("/").pop(); |
| 27 | return `https://github.com/cloudflare/kumo/blob/main/packages/kumo/src/${sourceFile}/${componentName}.tsx`; |
| 28 | })() |
| 29 | : null; |
| 30 | --- |
| 31 | |
| 32 | <MainLayout title={`${title} - Kumo`} description={description}> |
| 33 | <div class="flex flex-col"> |
| 34 | |
| 35 | <StickyDocHeader |
| 36 | title={title} |
| 37 | githubSourceUrl={githubSourceUrl} |
| 38 | baseUIUrl={baseUIUrl} |
| 39 | client:load |
| 40 | /> |
| 41 | |
| 42 | <!-- Page Header --> |
| 43 | <div |
| 44 | id="page-header" |
| 45 | class="border-b border-kumo-line md:pr-12" |
| 46 | > |
| 47 | <div |
| 48 | class="mx-auto md:border-r md:border-kumo-line" |
| 49 | > |
| 50 | <div class="mx-auto max-w-5xl px-8 py-12"> |
| 51 | <div class="mb-3 flex items-center gap-3"> |
| 52 | <h1 class="text-4xl font-bold text-kumo-default">{title}</h1> |
| 53 | { |
| 54 | githubSourceUrl && ( |
| 55 | <a |
| 56 | href={githubSourceUrl} |
| 57 | target="_blank" |
| 58 | rel="noopener noreferrer" |
| 59 | class="text-kumo-subtle transition-colors hover:text-kumo-strong" |
| 60 | title="View source on GitHub" |
| 61 | aria-label="View source on GitHub" |
| 62 | > |
| 63 | <GithubLogo size={28} weight="fill" /> |
| 64 | </a> |
| 65 | ) |
| 66 | } |
| 67 | { |
| 68 | baseUIUrl && ( |
| 69 | <a |
| 70 | href={baseUIUrl} |
| 71 | target="_blank" |
| 72 | rel="noopener noreferrer" |
| 73 | class="text-kumo-subtle transition-colors hover:text-kumo-strong" |
| 74 | title="View Base UI documentation" |
| 75 | aria-label="View Base UI documentation" |
| 76 | > |
| 77 | <BaseUIIcon size={28} /> |
| 78 | </a> |
| 79 | ) |
| 80 | } |
| 81 | </div> |
| 82 | <p class="text-lg text-kumo-strong"> |
| 83 | {description} |
| 84 | </p> |
| 85 | </div> |
| 86 | </div> |
| 87 | </div> |
| 88 | |
| 89 | <!-- Content --> |
| 90 | <main class="flex grow flex-col md:pr-12"> |
| 91 | <div |
| 92 | class="mx-auto w-full grow md:border-r md:border-kumo-line" |
| 93 | > |
| 94 | <div class="mx-auto max-w-5xl px-8 py-12"> |
| 95 | <div class="max-w-none"> |
| 96 | <slot /> |
| 97 | </div> |
| 98 | </div> |
| 99 | </div> |
| 100 | </main> |
| 101 | </div> |
| 102 | </MainLayout> |
| 103 | |