doccupine 0.0.136 → 0.0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/structures.js +6 -0
- package/dist/templates/components/Docs.d.ts +1 -1
- package/dist/templates/components/Docs.js +7 -2
- package/dist/templates/components/MDXComponents.d.ts +1 -1
- package/dist/templates/components/MDXComponents.js +2 -0
- package/dist/templates/components/SideBar.d.ts +1 -1
- package/dist/templates/components/SideBar.js +5 -0
- package/dist/templates/components/layout/Badge.d.ts +1 -1
- package/dist/templates/components/layout/Badge.js +16 -5
- package/dist/templates/components/layout/DocsComponents.d.ts +1 -1
- package/dist/templates/components/layout/DocsComponents.js +10 -0
- package/dist/templates/components/layout/DocsNavigation.d.ts +1 -1
- package/dist/templates/components/layout/DocsNavigation.js +8 -1
- package/dist/templates/components/layout/FocusModeToggle.d.ts +1 -0
- package/dist/templates/components/layout/FocusModeToggle.js +103 -0
- package/dist/templates/components/layout/Footer.d.ts +1 -1
- package/dist/templates/components/layout/Footer.js +7 -0
- package/dist/templates/components/layout/SharedStyles.d.ts +1 -1
- package/dist/templates/components/layout/SharedStyles.js +47 -0
- package/dist/templates/components/layout/SidePanel.d.ts +1 -0
- package/dist/templates/components/layout/SidePanel.js +65 -0
- package/dist/templates/components/layout/StaticLinks.d.ts +1 -1
- package/dist/templates/components/layout/StaticLinks.js +8 -1
- package/dist/templates/mdx/api-playground.mdx.d.ts +1 -1
- package/dist/templates/mdx/api-playground.mdx.js +1 -1
- package/dist/templates/mdx/badges.mdx.d.ts +1 -1
- package/dist/templates/mdx/badges.mdx.js +2 -0
- package/dist/templates/mdx/color-swatches.mdx.d.ts +1 -1
- package/dist/templates/mdx/color-swatches.mdx.js +1 -1
- package/dist/templates/mdx/components.mdx.d.ts +1 -1
- package/dist/templates/mdx/components.mdx.js +3 -0
- package/dist/templates/mdx/fields.mdx.d.ts +1 -1
- package/dist/templates/mdx/fields.mdx.js +1 -1
- package/dist/templates/mdx/mermaid.mdx.d.ts +1 -1
- package/dist/templates/mdx/mermaid.mdx.js +1 -1
- package/dist/templates/mdx/navigation.mdx.d.ts +1 -1
- package/dist/templates/mdx/navigation.mdx.js +1 -0
- package/dist/templates/mdx/side-panel.mdx.d.ts +1 -0
- package/dist/templates/mdx/side-panel.mdx.js +62 -0
- package/dist/templates/mdx/update.mdx.d.ts +1 -1
- package/dist/templates/mdx/update.mdx.js +1 -1
- package/dist/templates/package.js +2 -2
- package/package.json +2 -2
package/dist/lib/structures.js
CHANGED
|
@@ -45,6 +45,7 @@ import { demoThemeTemplate } from "../templates/components/layout/DemoTheme.js";
|
|
|
45
45
|
import { docsComponentsTemplate } from "../templates/components/layout/DocsComponents.js";
|
|
46
46
|
import { docsNavigationTemplate } from "../templates/components/layout/DocsNavigation.js";
|
|
47
47
|
import { fieldTemplate } from "../templates/components/layout/Field.js";
|
|
48
|
+
import { focusModeToggleTemplate } from "../templates/components/layout/FocusModeToggle.js";
|
|
48
49
|
import { footerTemplate } from "../templates/components/layout/Footer.js";
|
|
49
50
|
import { frameTemplate } from "../templates/components/layout/Frame.js";
|
|
50
51
|
import { globalStylesTemplate } from "../templates/components/layout/GlobalStyles.js";
|
|
@@ -53,6 +54,7 @@ import { iconTemplate } from "../templates/components/layout/Icon.js";
|
|
|
53
54
|
import { pictogramsTemplate } from "../templates/components/layout/Pictograms.js";
|
|
54
55
|
import { promptTemplate } from "../templates/components/layout/Prompt.js";
|
|
55
56
|
import { sharedStyledTemplate } from "../templates/components/layout/SharedStyles.js";
|
|
57
|
+
import { sidePanelTemplate } from "../templates/components/layout/SidePanel.js";
|
|
56
58
|
import { notFoundComponentTemplate } from "../templates/components/layout/NotFound.js";
|
|
57
59
|
import { siteGateComponentTemplate } from "../templates/components/layout/SiteGate.js";
|
|
58
60
|
import { slugTemplate } from "../templates/components/layout/Slug.js";
|
|
@@ -124,6 +126,7 @@ import { mcpMdxTemplate } from "../templates/mdx/model-context-protocol.mdx.js";
|
|
|
124
126
|
import { navigationMdxTemplate } from "../templates/mdx/navigation.mdx.js";
|
|
125
127
|
import { promptMdxTemplate } from "../templates/mdx/prompt.mdx.js";
|
|
126
128
|
import { sectionsMdxTemplate } from "../templates/mdx/sections.mdx.js";
|
|
129
|
+
import { sidePanelMdxTemplate } from "../templates/mdx/side-panel.mdx.js";
|
|
127
130
|
import { stepsMdxTemplate } from "../templates/mdx/steps.mdx.js";
|
|
128
131
|
import { tabsMdxTemplate } from "../templates/mdx/tabs.mdx.js";
|
|
129
132
|
import { themeMdxTemplate } from "../templates/mdx/theme.mdx.js";
|
|
@@ -227,6 +230,7 @@ export const appStructure = {
|
|
|
227
230
|
"components/layout/DocsNavigation.tsx": docsNavigationTemplate,
|
|
228
231
|
"components/layout/SectionBar.tsx": sectionBarTemplate,
|
|
229
232
|
"components/layout/Field.tsx": fieldTemplate,
|
|
233
|
+
"components/layout/FocusModeToggle.tsx": focusModeToggleTemplate,
|
|
230
234
|
"components/layout/Footer.tsx": footerTemplate,
|
|
231
235
|
"components/layout/Frame.tsx": frameTemplate,
|
|
232
236
|
"components/layout/GlobalStyles.ts": globalStylesTemplate,
|
|
@@ -236,6 +240,7 @@ export const appStructure = {
|
|
|
236
240
|
"components/layout/Pictograms.tsx": pictogramsTemplate,
|
|
237
241
|
"components/layout/Prompt.tsx": promptTemplate,
|
|
238
242
|
"components/layout/SharedStyled.ts": sharedStyledTemplate,
|
|
243
|
+
"components/layout/SidePanel.tsx": sidePanelTemplate,
|
|
239
244
|
"components/layout/NotFound.tsx": notFoundComponentTemplate,
|
|
240
245
|
"components/layout/SiteGate.tsx": siteGateComponentTemplate,
|
|
241
246
|
"components/layout/Slug.ts": slugTemplate,
|
|
@@ -289,6 +294,7 @@ export const startingDocsStructure = {
|
|
|
289
294
|
"navigation.mdx": navigationMdxTemplate,
|
|
290
295
|
"prompt.mdx": promptMdxTemplate,
|
|
291
296
|
"sections.mdx": sectionsMdxTemplate,
|
|
297
|
+
"side-panel.mdx": sidePanelMdxTemplate,
|
|
292
298
|
"steps.mdx": stepsMdxTemplate,
|
|
293
299
|
"tabs.mdx": tabsMdxTemplate,
|
|
294
300
|
"theme.mdx": themeMdxTemplate,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const docsTemplate = "import React from \"react\";\nimport { Flex } from \"cherry-styled-components\";\nimport {\n DocsContainer,\n StyledMarkdownContainer,\n StyledMissingComponent,\n} from \"@/components/layout/DocsComponents\";\nimport { MDXRemote } from \"next-mdx-remote/rsc\";\nimport remarkGfm from \"remark-gfm\";\nimport { useMDXComponents } from \"@/components/MDXComponents\";\nimport { createMermaidPre } from \"@/components/MermaidPre\";\nimport { DocsSideBar } from \"@/components/DocsSideBar\";\nimport { ActionBar } from \"@/components/layout/ActionBar\";\nimport { ApiPlaygroundDemo } from \"@/components/layout/ApiPlaygroundDemo\";\nimport { createSlugger } from \"@/components/layout/Slug\";\nimport { rehypeCodeMeta } from \"@/utils/rehypeCodeMeta\";\n\ninterface DocsProps {\n content: string;\n sourcePath?: string;\n // Path of this page's RSS feed; when set, the action bar shows an RSS\n // button linking to it.\n rssHref?: string;\n // Extra content rendered inside the markdown column, after the MDX body.\n // Used to place generated widgets (e.g. the API playground) inside the docs\n // content area rather than outside its layout.\n children?: React.ReactNode;\n}\n\ninterface Heading {\n id: string;\n text: string;\n level: number;\n}\n\nfunction extractHeadings(content: string): Heading[] {\n const contentWithoutCodeBlocks = content.replace(/```[\\s\\S]*?```/g, \"\");\n const entries: { text: string; level: number; position: number }[] = [];\n let match;\n\n // Markdown headings (# .. ######)\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n while ((match = headingRegex.exec(contentWithoutCodeBlocks)) !== null) {\n const level = match[1].length;\n const text = match[2].trim();\n entries.push({ text, level, position: match.index });\n }\n\n // <Update label=\"...\"> blocks surface their label as a top-level entry\n const updateRegex = /<Update\\b[^>]*?\\blabel=[\"']([^\"']+)[\"'][^>]*>/g;\n while ((match = updateRegex.exec(contentWithoutCodeBlocks)) !== null) {\n entries.push({ text: match[1].trim(), level: 1, position: match.index });\n }\n\n // Assign ids in document order with a shared slugger so repeated heading\n // text produces unique anchors (\"setup\", \"setup-1\", ...) that stay in sync\n // with the ids rendered by MDXComponents/Update.\n const slug = createSlugger();\n return entries\n .sort((a, b) => a.position - b.position)\n .map(({ text, level }) => ({ id: slug(text), text, level }));\n}\n\nfunction extractComponentNames(source: string): string[] {\n const stripped = source\n .replace(/```[\\s\\S]*?```/g, \"\")\n .replace(/`[^`]*`/g, \"\");\n const tagRegex = /<([A-Z][a-zA-Z0-9]*)/g;\n const names = new Set<string>();\n let match;\n while ((match = tagRegex.exec(stripped)) !== null) {\n names.add(match[1]);\n }\n return Array.from(names);\n}\n\nfunction MissingComponent({\n componentName,\n children: _children,\n}: {\n componentName: string;\n children?: React.ReactNode;\n}) {\n return (\n <StyledMissingComponent>\n Missing component: <{componentName} />\n </StyledMissingComponent>\n );\n}\n\nfunction Docs({ content, sourcePath, rssHref, children }: DocsProps) {\n const
|
|
1
|
+
export declare const docsTemplate = "import React from \"react\";\nimport { Flex } from \"cherry-styled-components\";\nimport {\n DocsContainer,\n StyledMarkdownContainer,\n StyledMissingComponent,\n} from \"@/components/layout/DocsComponents\";\nimport { MDXRemote } from \"next-mdx-remote/rsc\";\nimport remarkGfm from \"remark-gfm\";\nimport { useMDXComponents } from \"@/components/MDXComponents\";\nimport { createMermaidPre } from \"@/components/MermaidPre\";\nimport { DocsSideBar } from \"@/components/DocsSideBar\";\nimport { ActionBar } from \"@/components/layout/ActionBar\";\nimport { ApiPlaygroundDemo } from \"@/components/layout/ApiPlaygroundDemo\";\nimport { createSlugger } from \"@/components/layout/Slug\";\nimport { rehypeCodeMeta } from \"@/utils/rehypeCodeMeta\";\n\ninterface DocsProps {\n content: string;\n sourcePath?: string;\n // Path of this page's RSS feed; when set, the action bar shows an RSS\n // button linking to it.\n rssHref?: string;\n // Extra content rendered inside the markdown column, after the MDX body.\n // Used to place generated widgets (e.g. the API playground) inside the docs\n // content area rather than outside its layout.\n children?: React.ReactNode;\n}\n\ninterface Heading {\n id: string;\n text: string;\n level: number;\n}\n\nfunction extractHeadings(content: string): Heading[] {\n const contentWithoutCodeBlocks = content.replace(/```[\\s\\S]*?```/g, \"\");\n const entries: { text: string; level: number; position: number }[] = [];\n let match;\n\n // Markdown headings (# .. ######)\n const headingRegex = /^(#{1,6})\\s+(.+)$/gm;\n while ((match = headingRegex.exec(contentWithoutCodeBlocks)) !== null) {\n const level = match[1].length;\n const text = match[2].trim();\n entries.push({ text, level, position: match.index });\n }\n\n // <Update label=\"...\"> blocks surface their label as a top-level entry\n const updateRegex = /<Update\\b[^>]*?\\blabel=[\"']([^\"']+)[\"'][^>]*>/g;\n while ((match = updateRegex.exec(contentWithoutCodeBlocks)) !== null) {\n entries.push({ text: match[1].trim(), level: 1, position: match.index });\n }\n\n // Assign ids in document order with a shared slugger so repeated heading\n // text produces unique anchors (\"setup\", \"setup-1\", ...) that stay in sync\n // with the ids rendered by MDXComponents/Update.\n const slug = createSlugger();\n return entries\n .sort((a, b) => a.position - b.position)\n .map(({ text, level }) => ({ id: slug(text), text, level }));\n}\n\nfunction extractComponentNames(source: string): string[] {\n const stripped = source\n .replace(/```[\\s\\S]*?```/g, \"\")\n .replace(/`[^`]*`/g, \"\");\n const tagRegex = /<([A-Z][a-zA-Z0-9]*)/g;\n const names = new Set<string>();\n let match;\n while ((match = tagRegex.exec(stripped)) !== null) {\n names.add(match[1]);\n }\n return Array.from(names);\n}\n\nfunction MissingComponent({\n componentName,\n children: _children,\n}: {\n componentName: string;\n children?: React.ReactNode;\n}) {\n return (\n <StyledMissingComponent>\n Missing component: <{componentName} />\n </StyledMissingComponent>\n );\n}\n\nfunction Docs({ content, sourcePath, rssHref, children }: DocsProps) {\n const components = useMDXComponents({\n pre: createMermaidPre(sourcePath),\n ApiPlaygroundDemo,\n });\n\n const knownNames = Object.keys(components);\n const usedNames = extractComponentNames(content);\n const missingNames = usedNames.filter((name) => !knownNames.includes(name));\n\n // A <SidePanel> takes over the right rail, so the table of contents that\n // normally lives there is dropped for that page. extractComponentNames\n // ignores code blocks, so a panel shown only as a code sample never counts.\n const hasSidePanel = usedNames.includes(\"SidePanel\");\n const headings = hasSidePanel ? [] : extractHeadings(content);\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const stubs: Record<string, React.ComponentType<any>> = {};\n for (const name of missingNames) {\n stubs[name] = ({ children }: { children?: React.ReactNode }) => (\n <MissingComponent componentName={name}>{children}</MissingComponent>\n );\n }\n\n const allComponents = { ...components, ...stubs };\n\n return (\n <>\n <DocsContainer>\n <ActionBar content={content} rssHref={rssHref}>\n <Flex $gap={20}>\n <StyledMarkdownContainer>\n {children}\n {content && (\n <MDXRemote\n source={content}\n options={{\n blockJS: false,\n mdxOptions: {\n remarkPlugins: [remarkGfm],\n rehypePlugins: [rehypeCodeMeta],\n },\n }}\n components={allComponents}\n />\n )}\n </StyledMarkdownContainer>\n </Flex>\n </ActionBar>\n </DocsContainer>\n {!hasSidePanel && <DocsSideBar headings={headings} />}\n </>\n );\n}\n\nexport { Docs };\n";
|
|
@@ -89,7 +89,6 @@ function MissingComponent({
|
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
function Docs({ content, sourcePath, rssHref, children }: DocsProps) {
|
|
92
|
-
const headings = extractHeadings(content);
|
|
93
92
|
const components = useMDXComponents({
|
|
94
93
|
pre: createMermaidPre(sourcePath),
|
|
95
94
|
ApiPlaygroundDemo,
|
|
@@ -99,6 +98,12 @@ function Docs({ content, sourcePath, rssHref, children }: DocsProps) {
|
|
|
99
98
|
const usedNames = extractComponentNames(content);
|
|
100
99
|
const missingNames = usedNames.filter((name) => !knownNames.includes(name));
|
|
101
100
|
|
|
101
|
+
// A <SidePanel> takes over the right rail, so the table of contents that
|
|
102
|
+
// normally lives there is dropped for that page. extractComponentNames
|
|
103
|
+
// ignores code blocks, so a panel shown only as a code sample never counts.
|
|
104
|
+
const hasSidePanel = usedNames.includes("SidePanel");
|
|
105
|
+
const headings = hasSidePanel ? [] : extractHeadings(content);
|
|
106
|
+
|
|
102
107
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
103
108
|
const stubs: Record<string, React.ComponentType<any>> = {};
|
|
104
109
|
for (const name of missingNames) {
|
|
@@ -133,7 +138,7 @@ function Docs({ content, sourcePath, rssHref, children }: DocsProps) {
|
|
|
133
138
|
</Flex>
|
|
134
139
|
</ActionBar>
|
|
135
140
|
</DocsContainer>
|
|
136
|
-
<DocsSideBar headings={headings} />
|
|
141
|
+
{!hasSidePanel && <DocsSideBar headings={headings} />}
|
|
137
142
|
</>
|
|
138
143
|
);
|
|
139
144
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const mdxComponentsTemplate = "import React from \"react\";\nimport Link from \"next/link\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MDXComponents = Record<string, React.ComponentType<any>>;\nimport { Space } from \"cherry-styled-components\";\nimport { Badge } from \"@/components/layout/Badge\";\nimport { Code as CodeBlock, CodeTabs } from \"@/components/layout/Code\";\nimport { Card } from \"@/components/layout/Card\";\nimport { Accordion } from \"@/components/layout/Accordion\";\nimport { Tabs, TabContent } from \"@/components/layout/Tabs\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { Columns } from \"@/components/layout/Columns\";\nimport { Field } from \"@/components/layout/Field\";\nimport { Frame } from \"@/components/layout/Frame\";\nimport { Prompt } from \"@/components/layout/Prompt\";\nimport { Update } from \"@/components/layout/Update\";\nimport { Steps, Step } from \"@/components/layout/Steps\";\nimport { Button } from \"@/components/layout/Button\";\nimport { ColorSwatch, ColorSwatchGroup } from \"@/components/layout/ColorSwatch\";\nimport { DemoTheme } from \"@/components/layout/DemoTheme\";\nimport { Tooltip } from \"@/components/layout/Tooltip\";\nimport { Tree as TreeRoot } from \"@/components/layout/Tree\";\nimport {\n parseTreeChildren,\n TreeFolder,\n TreeFile,\n} from \"@/components/layout/TreeData\";\nimport { createSlugger } from \"@/components/layout/Slug\";\n\ninterface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n children?: React.ReactNode;\n}\n\ninterface PreProps extends React.HTMLAttributes<HTMLPreElement> {\n children?: React.ReactNode;\n}\n\n// The Tree compound is assembled here in shared code: statics attached to\n// the client component would not survive the client-reference boundary, and\n// the Tree.Folder / Tree.File elements MDX creates must be parsed in the\n// same runtime that created them, where marker identity is guaranteed. Only\n// the resulting plain TreeNode data crosses to the client component.\nconst Tree = Object.assign(\n function Tree({ children }: { children?: React.ReactNode }) {\n return <TreeRoot nodes={parseTreeChildren(children, \"node\")} />;\n },\n { Folder: TreeFolder, File: TreeFile },\n);\n\n// <Tree> and <FileTree> are aliases; either tag supports either syntax.\nconst FileTree = Tree;\n\nexport function extractAllTextFromChildren(children: React.ReactNode): string {\n if (children == null) return \"\";\n if (typeof children === \"string\") return children;\n if (typeof children === \"number\") return String(children);\n if (typeof children === \"boolean\") return \"\";\n if (Array.isArray(children))\n return children.map(extractAllTextFromChildren).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractAllTextFromChildren(element.props.children);\n }\n return \"\";\n}\n\n// Map <pre><code class=\"language-xyz\"> to our <Code /> component\nexport function Pre(props: PreProps) {\n const child = React.Children.only(props.children) as React.ReactElement<{\n className?: string;\n children?: React.ReactNode;\n }> | null;\n if (child && child.type === \"code\") {\n const className = child.props.className || \"\";\n const match = /language-(\\w+)/.exec(className);\n const language = match ? match[1] : undefined;\n const code = extractAllTextFromChildren(child.props.children).replace(\n /\\n$/,\n \"\",\n );\n if (language) {\n return (\n <CodeBlock className={className} code={code} language={language} />\n );\n }\n }\n return <pre {...props} />;\n}\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n // One slugger per render so repeated heading text (and <Update> labels)\n // resolve to unique, document-order ids that match the index sidebar built\n // in components/Docs.tsx.\n const slug = createSlugger();\n return {\n // Headings with auto-generated ids for TOC and deep links\n h1: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h1 id={id} {...props}>\n {children}\n </h1>\n );\n },\n h2: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h2 id={id} {...props}>\n {children}\n </h2>\n );\n },\n h3: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h3 id={id} {...props}>\n {children}\n </h3>\n );\n },\n h4: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h4 id={id} {...props}>\n {children}\n </h4>\n );\n },\n h5: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h5 id={id} {...props}>\n {children}\n </h5>\n );\n },\n h6: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h6 id={id} {...props}>\n {children}\n </h6>\n );\n },\n\n // Links - use Next.js Link for internal paths\n a: ({\n href,\n children,\n ...props\n }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {\n if (href && href.startsWith(\"/\")) {\n return (\n <Link href={href} {...props}>\n {children}\n </Link>\n );\n }\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n );\n },\n\n // Tables - wrap in a div for responsive overflow\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"table-wrapper\">\n <table {...props} />\n </div>\n ),\n\n // Code blocks\n pre: Pre,\n\n // Expose your custom components for MDX usage\n Badge,\n Code: CodeBlock,\n CodeTabs,\n Card,\n Accordion,\n Tabs,\n TabContent,\n Callout,\n Icon,\n Columns,\n Field,\n Frame,\n Prompt,\n // Share the heading slugger so an <Update> label anchor stays unique and\n // in document order alongside the surrounding headings. Only consume a\n // slug when a label is present so a label-less <Update> does not crash the\n // slugger (Update itself renders gracefully without a label anchor).\n Update: (props: React.ComponentProps<typeof Update>) => (\n <Update {...props} id={props.label ? slug(props.label) : undefined} />\n ),\n Steps,\n Step,\n Button,\n ColorSwatch,\n ColorSwatchGroup,\n DemoTheme,\n Tooltip,\n Tree,\n FileTree,\n Space,\n ...components,\n };\n}\n";
|
|
1
|
+
export declare const mdxComponentsTemplate = "import React from \"react\";\nimport Link from \"next/link\";\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype MDXComponents = Record<string, React.ComponentType<any>>;\nimport { Space } from \"cherry-styled-components\";\nimport { Badge } from \"@/components/layout/Badge\";\nimport { Code as CodeBlock, CodeTabs } from \"@/components/layout/Code\";\nimport { Card } from \"@/components/layout/Card\";\nimport { Accordion } from \"@/components/layout/Accordion\";\nimport { Tabs, TabContent } from \"@/components/layout/Tabs\";\nimport { Callout } from \"@/components/layout/Callout\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { Columns } from \"@/components/layout/Columns\";\nimport { Field } from \"@/components/layout/Field\";\nimport { Frame } from \"@/components/layout/Frame\";\nimport { Prompt } from \"@/components/layout/Prompt\";\nimport { SidePanel } from \"@/components/layout/SidePanel\";\nimport { Update } from \"@/components/layout/Update\";\nimport { Steps, Step } from \"@/components/layout/Steps\";\nimport { Button } from \"@/components/layout/Button\";\nimport { ColorSwatch, ColorSwatchGroup } from \"@/components/layout/ColorSwatch\";\nimport { DemoTheme } from \"@/components/layout/DemoTheme\";\nimport { Tooltip } from \"@/components/layout/Tooltip\";\nimport { Tree as TreeRoot } from \"@/components/layout/Tree\";\nimport {\n parseTreeChildren,\n TreeFolder,\n TreeFile,\n} from \"@/components/layout/TreeData\";\nimport { createSlugger } from \"@/components/layout/Slug\";\n\ninterface HeadingProps extends React.HTMLAttributes<HTMLHeadingElement> {\n children?: React.ReactNode;\n}\n\ninterface PreProps extends React.HTMLAttributes<HTMLPreElement> {\n children?: React.ReactNode;\n}\n\n// The Tree compound is assembled here in shared code: statics attached to\n// the client component would not survive the client-reference boundary, and\n// the Tree.Folder / Tree.File elements MDX creates must be parsed in the\n// same runtime that created them, where marker identity is guaranteed. Only\n// the resulting plain TreeNode data crosses to the client component.\nconst Tree = Object.assign(\n function Tree({ children }: { children?: React.ReactNode }) {\n return <TreeRoot nodes={parseTreeChildren(children, \"node\")} />;\n },\n { Folder: TreeFolder, File: TreeFile },\n);\n\n// <Tree> and <FileTree> are aliases; either tag supports either syntax.\nconst FileTree = Tree;\n\nexport function extractAllTextFromChildren(children: React.ReactNode): string {\n if (children == null) return \"\";\n if (typeof children === \"string\") return children;\n if (typeof children === \"number\") return String(children);\n if (typeof children === \"boolean\") return \"\";\n if (Array.isArray(children))\n return children.map(extractAllTextFromChildren).join(\"\");\n if (React.isValidElement(children)) {\n const element = children as React.ReactElement<{\n children?: React.ReactNode;\n }>;\n return extractAllTextFromChildren(element.props.children);\n }\n return \"\";\n}\n\n// Map <pre><code class=\"language-xyz\"> to our <Code /> component\nexport function Pre(props: PreProps) {\n const child = React.Children.only(props.children) as React.ReactElement<{\n className?: string;\n children?: React.ReactNode;\n }> | null;\n if (child && child.type === \"code\") {\n const className = child.props.className || \"\";\n const match = /language-(\\w+)/.exec(className);\n const language = match ? match[1] : undefined;\n const code = extractAllTextFromChildren(child.props.children).replace(\n /\\n$/,\n \"\",\n );\n if (language) {\n return (\n <CodeBlock className={className} code={code} language={language} />\n );\n }\n }\n return <pre {...props} />;\n}\n\nexport function useMDXComponents(components: MDXComponents): MDXComponents {\n // One slugger per render so repeated heading text (and <Update> labels)\n // resolve to unique, document-order ids that match the index sidebar built\n // in components/Docs.tsx.\n const slug = createSlugger();\n return {\n // Headings with auto-generated ids for TOC and deep links\n h1: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h1 id={id} {...props}>\n {children}\n </h1>\n );\n },\n h2: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h2 id={id} {...props}>\n {children}\n </h2>\n );\n },\n h3: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h3 id={id} {...props}>\n {children}\n </h3>\n );\n },\n h4: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h4 id={id} {...props}>\n {children}\n </h4>\n );\n },\n h5: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h5 id={id} {...props}>\n {children}\n </h5>\n );\n },\n h6: ({ children, ...props }: HeadingProps) => {\n const id = slug(extractAllTextFromChildren(children));\n return (\n <h6 id={id} {...props}>\n {children}\n </h6>\n );\n },\n\n // Links - use Next.js Link for internal paths\n a: ({\n href,\n children,\n ...props\n }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {\n if (href && href.startsWith(\"/\")) {\n return (\n <Link href={href} {...props}>\n {children}\n </Link>\n );\n }\n return (\n <a href={href} target=\"_blank\" rel=\"noopener noreferrer\" {...props}>\n {children}\n </a>\n );\n },\n\n // Tables - wrap in a div for responsive overflow\n table: (props: React.TableHTMLAttributes<HTMLTableElement>) => (\n <div className=\"table-wrapper\">\n <table {...props} />\n </div>\n ),\n\n // Code blocks\n pre: Pre,\n\n // Expose your custom components for MDX usage\n Badge,\n Code: CodeBlock,\n CodeTabs,\n Card,\n Accordion,\n Tabs,\n TabContent,\n Callout,\n Icon,\n Columns,\n Field,\n Frame,\n Prompt,\n SidePanel,\n // Share the heading slugger so an <Update> label anchor stays unique and\n // in document order alongside the surrounding headings. Only consume a\n // slug when a label is present so a label-less <Update> does not crash the\n // slugger (Update itself renders gracefully without a label anchor).\n Update: (props: React.ComponentProps<typeof Update>) => (\n <Update {...props} id={props.label ? slug(props.label) : undefined} />\n ),\n Steps,\n Step,\n Button,\n ColorSwatch,\n ColorSwatchGroup,\n DemoTheme,\n Tooltip,\n Tree,\n FileTree,\n Space,\n ...components,\n };\n}\n";
|
|
@@ -15,6 +15,7 @@ import { Columns } from "@/components/layout/Columns";
|
|
|
15
15
|
import { Field } from "@/components/layout/Field";
|
|
16
16
|
import { Frame } from "@/components/layout/Frame";
|
|
17
17
|
import { Prompt } from "@/components/layout/Prompt";
|
|
18
|
+
import { SidePanel } from "@/components/layout/SidePanel";
|
|
18
19
|
import { Update } from "@/components/layout/Update";
|
|
19
20
|
import { Steps, Step } from "@/components/layout/Steps";
|
|
20
21
|
import { Button } from "@/components/layout/Button";
|
|
@@ -191,6 +192,7 @@ export function useMDXComponents(components: MDXComponents): MDXComponents {
|
|
|
191
192
|
Field,
|
|
192
193
|
Frame,
|
|
193
194
|
Prompt,
|
|
195
|
+
SidePanel,
|
|
194
196
|
// Share the heading slugger so an <Update> label anchor stays unique and
|
|
195
197
|
// in document order alongside the surrounding headings. Only consume a
|
|
196
198
|
// slug when a label is present so a label-less <Update> does not crash the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const sideBarTemplate = "\"use client\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Flex, Space, ThemeToggle } from \"cherry-styled-components\";\nimport { httpMethodBadgeColor } from \"@/components/layout/Badge\";\nimport {\n DocsSidebar,\n SectionBarContext,\n StyledSidebar,\n StyledSidebarList,\n StyledSidebarListItem,\n StyledStrong,\n StyledSidebarListItemLink,\n StyledSidebarMethodTag,\n StyledSidebarGroupButton,\n StyledSidebarGroupRow,\n StyledSidebarGroupLink,\n StyledSidebarGroupChevron,\n StyledSidebarGroupContent,\n StyledSidebarFooter,\n StyleMobileBar,\n StyledMobileBurger,\n} from \"@/components/layout/DocsComponents\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { useLockBodyScroll } from \"@/components/LockBodyScroll\";\n\n// A link can be a leaf (slug + title) or a group with nested children. Both the\n// category icon and the per-link icon are optional Lucide names.\ntype NavItemLink = {\n slug?: string;\n title: string;\n icon?: string;\n httpMethod?: string;\n links?: NavItemLink[];\n};\n\ntype NavItem = {\n label: string;\n icon?: string;\n links: NavItemLink[];\n};\n\ninterface SideBarProps {\n result: NavItem[];\n}\n\nfunction linkContainsActivePath(link: NavItemLink, pathname: string): boolean {\n if (link.slug !== undefined && pathname === `/${link.slug}`) {\n return true;\n }\n return (link.links ?? []).some((child) =>\n linkContainsActivePath(child, pathname),\n );\n}\n\nfunction SidebarNavLink({\n link,\n depth,\n pathname,\n onNavigate,\n}: {\n link: NavItemLink;\n depth: number;\n pathname: string;\n onNavigate: () => void;\n}) {\n const children = link.links ?? [];\n const hasChildren = children.length > 0;\n const href = link.slug !== undefined ? `/${link.slug}` : undefined;\n const isActive = href !== undefined && pathname === href;\n const indent = { paddingLeft: `${20 + depth * 14}px` };\n\n // Open collapsible groups that contain the active page so deep links land\n // with their ancestors already expanded.\n const [isOpen, setIsOpen] = useState(\n hasChildren\n ? children.some((child) => linkContainsActivePath(child, pathname))\n : false,\n );\n\n if (!hasChildren) {\n return (\n <StyledSidebarListItem>\n <StyledSidebarListItemLink\n href={href ?? \"#\"}\n $isActive={isActive}\n aria-current={isActive ? \"page\" : undefined}\n onClick={onNavigate}\n style={indent}\n >\n {link.httpMethod && (\n <StyledSidebarMethodTag\n mono\n solid={isActive}\n size=\"xs\"\n color={httpMethodBadgeColor(link.httpMethod)}\n >\n {link.httpMethod}\n </StyledSidebarMethodTag>\n )}\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarListItemLink>\n </StyledSidebarListItem>\n );\n }\n\n const toggle = () => setIsOpen((prev) => !prev);\n const toggleLabel = isOpen\n ? `Collapse ${link.title}`\n : `Expand ${link.title}`;\n const groupActive = linkContainsActivePath(link, pathname);\n\n return (\n <li>\n {href !== undefined ? (\n <StyledSidebarGroupRow\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n >\n <StyledSidebarGroupLink\n href={href}\n aria-current={pathname === href ? \"page\" : undefined}\n onClick={onNavigate}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarGroupLink>\n <StyledSidebarGroupChevron\n type=\"button\"\n onClick={toggle}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupChevron>\n </StyledSidebarGroupRow>\n ) : (\n <StyledSidebarGroupButton\n type=\"button\"\n onClick={toggle}\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupButton>\n )}\n <StyledSidebarGroupContent $isOpen={isOpen}>\n {children.map((child: NavItemLink, index: number) => (\n <SidebarNavLink\n key={index}\n link={child}\n depth={depth + 1}\n pathname={pathname}\n onNavigate={onNavigate}\n />\n ))}\n </StyledSidebarGroupContent>\n </li>\n );\n}\n\nfunction SideBar({ result }: SideBarProps) {\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n const hasSectionBar = useContext(SectionBarContext);\n const pathname = usePathname();\n const navRef = useRef<HTMLElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n\n useLockBodyScroll(isMobileMenuOpen);\n\n // Bring the current page's link into view within the sidebar's own scroll\n // area when it starts off-screen (deep pages, in-content links, search).\n // Scoped to the nav via scrollTo so the main document never jumps.\n useEffect(() => {\n const nav = navRef.current;\n if (!nav) return;\n const active = nav.querySelector<HTMLElement>('[aria-current=\"page\"]');\n if (!active) return;\n\n const navRect = nav.getBoundingClientRect();\n const activeRect = active.getBoundingClientRect();\n\n // The theme-toggle footer is sticky over the bottom of the scroll area\n // (~60px tall), so links underneath it are covered rather than visible.\n // Clamp the visible bottom to the footer's top edge when it's pinned.\n const footerRect = footerRef.current?.getBoundingClientRect();\n const visibleBottom = footerRect\n ? Math.min(navRect.bottom, footerRect.top)\n : navRect.bottom;\n\n const isOutOfView =\n activeRect.top < navRect.top || activeRect.bottom > visibleBottom;\n if (!isOutOfView) return;\n\n // Center within the visible band (nav top .. footer top), not the full\n // nav height, so the link never settles behind the footer.\n const visibleHeight = visibleBottom - navRect.top;\n const target =\n nav.scrollTop +\n (activeRect.top - navRect.top) -\n (visibleHeight - active.clientHeight) / 2;\n\n // Animate the scroll, but honor users who opt out of motion.\n const prefersReducedMotion = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\",\n ).matches;\n nav.scrollTo({\n top: Math.max(0, target),\n behavior: prefersReducedMotion ? \"auto\" : \"smooth\",\n });\n }, [pathname]);\n\n return (\n <DocsSidebar>\n <StyleMobileBar\n onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}\n $isActive={isMobileMenuOpen}\n aria-label={\n isMobileMenuOpen ? \"Close navigation menu\" : \"Open navigation menu\"\n }\n aria-expanded={isMobileMenuOpen}\n >\n <StyledMobileBurger $isActive={isMobileMenuOpen} />\n </StyleMobileBar>\n\n <StyledSidebar\n ref={navRef}\n $isActive={isMobileMenuOpen}\n $hasSectionBar={hasSectionBar}\n >\n {result &&\n result.map((item: NavItem, index: number) => {\n return (\n <StyledSidebarList key={index}>\n <StyledSidebarListItem>\n <StyledStrong>\n {item.icon && <Icon name={item.icon} size={16} />}\n {item.label}\n </StyledStrong>{\" \"}\n </StyledSidebarListItem>\n <li>\n <Space $size={20} />\n </li>\n {item.links &&\n item.links.map((link: NavItemLink, indexChild: number) => (\n <SidebarNavLink\n key={indexChild}\n link={link}\n depth={0}\n pathname={pathname}\n onNavigate={() => setIsMobileMenuOpen(false)}\n />\n ))}\n <li aria-hidden=\"true\">\n <Space $size={20} />\n </li>\n </StyledSidebarList>\n );\n })}\n <StyledSidebarFooter ref={footerRef}>\n <Flex $xsJustifyContent=\"flex-start\" $lgJustifyContent=\"flex-end\">\n <ThemeToggle $shortcut />\n </Flex>\n </StyledSidebarFooter>\n </StyledSidebar>\n </DocsSidebar>\n );\n}\n\nexport { SideBar };\n";
|
|
1
|
+
export declare const sideBarTemplate = "\"use client\";\nimport { useContext, useEffect, useRef, useState } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport { Flex, Space, ThemeToggle } from \"cherry-styled-components\";\nimport { httpMethodBadgeColor } from \"@/components/layout/Badge\";\nimport {\n DocsSidebar,\n SectionBarContext,\n StyledSidebar,\n StyledSidebarList,\n StyledSidebarListItem,\n StyledStrong,\n StyledSidebarListItemLink,\n StyledSidebarMethodTag,\n StyledSidebarGroupButton,\n StyledSidebarGroupRow,\n StyledSidebarGroupLink,\n StyledSidebarGroupChevron,\n StyledSidebarGroupContent,\n StyledSidebarFooter,\n StyleMobileBar,\n StyledMobileBurger,\n} from \"@/components/layout/DocsComponents\";\nimport { FocusModeToggle } from \"@/components/layout/FocusModeToggle\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { useLockBodyScroll } from \"@/components/LockBodyScroll\";\n\n// A link can be a leaf (slug + title) or a group with nested children. Both the\n// category icon and the per-link icon are optional Lucide names.\ntype NavItemLink = {\n slug?: string;\n title: string;\n icon?: string;\n httpMethod?: string;\n links?: NavItemLink[];\n};\n\ntype NavItem = {\n label: string;\n icon?: string;\n links: NavItemLink[];\n};\n\ninterface SideBarProps {\n result: NavItem[];\n}\n\nfunction linkContainsActivePath(link: NavItemLink, pathname: string): boolean {\n if (link.slug !== undefined && pathname === `/${link.slug}`) {\n return true;\n }\n return (link.links ?? []).some((child) =>\n linkContainsActivePath(child, pathname),\n );\n}\n\nfunction SidebarNavLink({\n link,\n depth,\n pathname,\n onNavigate,\n}: {\n link: NavItemLink;\n depth: number;\n pathname: string;\n onNavigate: () => void;\n}) {\n const children = link.links ?? [];\n const hasChildren = children.length > 0;\n const href = link.slug !== undefined ? `/${link.slug}` : undefined;\n const isActive = href !== undefined && pathname === href;\n const indent = { paddingLeft: `${20 + depth * 14}px` };\n\n // Open collapsible groups that contain the active page so deep links land\n // with their ancestors already expanded.\n const [isOpen, setIsOpen] = useState(\n hasChildren\n ? children.some((child) => linkContainsActivePath(child, pathname))\n : false,\n );\n\n if (!hasChildren) {\n return (\n <StyledSidebarListItem>\n <StyledSidebarListItemLink\n href={href ?? \"#\"}\n $isActive={isActive}\n aria-current={isActive ? \"page\" : undefined}\n onClick={onNavigate}\n style={indent}\n >\n {link.httpMethod && (\n <StyledSidebarMethodTag\n mono\n solid={isActive}\n size=\"xs\"\n color={httpMethodBadgeColor(link.httpMethod)}\n >\n {link.httpMethod}\n </StyledSidebarMethodTag>\n )}\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarListItemLink>\n </StyledSidebarListItem>\n );\n }\n\n const toggle = () => setIsOpen((prev) => !prev);\n const toggleLabel = isOpen\n ? `Collapse ${link.title}`\n : `Expand ${link.title}`;\n const groupActive = linkContainsActivePath(link, pathname);\n\n return (\n <li>\n {href !== undefined ? (\n <StyledSidebarGroupRow\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n >\n <StyledSidebarGroupLink\n href={href}\n aria-current={pathname === href ? \"page\" : undefined}\n onClick={onNavigate}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n </StyledSidebarGroupLink>\n <StyledSidebarGroupChevron\n type=\"button\"\n onClick={toggle}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupChevron>\n </StyledSidebarGroupRow>\n ) : (\n <StyledSidebarGroupButton\n type=\"button\"\n onClick={toggle}\n $isActive={groupActive}\n $isOpen={isOpen}\n style={indent}\n aria-expanded={isOpen}\n aria-label={toggleLabel}\n >\n {link.icon && <Icon name={link.icon} size={16} />}\n {link.title}\n <Icon name=\"chevron-right\" size={16} />\n </StyledSidebarGroupButton>\n )}\n <StyledSidebarGroupContent $isOpen={isOpen}>\n {children.map((child: NavItemLink, index: number) => (\n <SidebarNavLink\n key={index}\n link={child}\n depth={depth + 1}\n pathname={pathname}\n onNavigate={onNavigate}\n />\n ))}\n </StyledSidebarGroupContent>\n </li>\n );\n}\n\nfunction SideBar({ result }: SideBarProps) {\n const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false);\n const hasSectionBar = useContext(SectionBarContext);\n const pathname = usePathname();\n const navRef = useRef<HTMLElement>(null);\n const footerRef = useRef<HTMLDivElement>(null);\n\n useLockBodyScroll(isMobileMenuOpen);\n\n // Bring the current page's link into view within the sidebar's own scroll\n // area when it starts off-screen (deep pages, in-content links, search).\n // Scoped to the nav via scrollTo so the main document never jumps.\n useEffect(() => {\n const nav = navRef.current;\n if (!nav) return;\n const active = nav.querySelector<HTMLElement>('[aria-current=\"page\"]');\n if (!active) return;\n\n const navRect = nav.getBoundingClientRect();\n const activeRect = active.getBoundingClientRect();\n\n // The theme-toggle footer is sticky over the bottom of the scroll area\n // (~60px tall), so links underneath it are covered rather than visible.\n // Clamp the visible bottom to the footer's top edge when it's pinned.\n const footerRect = footerRef.current?.getBoundingClientRect();\n const visibleBottom = footerRect\n ? Math.min(navRect.bottom, footerRect.top)\n : navRect.bottom;\n\n const isOutOfView =\n activeRect.top < navRect.top || activeRect.bottom > visibleBottom;\n if (!isOutOfView) return;\n\n // Center within the visible band (nav top .. footer top), not the full\n // nav height, so the link never settles behind the footer.\n const visibleHeight = visibleBottom - navRect.top;\n const target =\n nav.scrollTop +\n (activeRect.top - navRect.top) -\n (visibleHeight - active.clientHeight) / 2;\n\n // Animate the scroll, but honor users who opt out of motion.\n const prefersReducedMotion = window.matchMedia(\n \"(prefers-reduced-motion: reduce)\",\n ).matches;\n nav.scrollTo({\n top: Math.max(0, target),\n behavior: prefersReducedMotion ? \"auto\" : \"smooth\",\n });\n }, [pathname]);\n\n return (\n <DocsSidebar>\n <StyleMobileBar\n onClick={() => setIsMobileMenuOpen(!isMobileMenuOpen)}\n $isActive={isMobileMenuOpen}\n aria-label={\n isMobileMenuOpen ? \"Close navigation menu\" : \"Open navigation menu\"\n }\n aria-expanded={isMobileMenuOpen}\n >\n <StyledMobileBurger $isActive={isMobileMenuOpen} />\n </StyleMobileBar>\n\n <StyledSidebar\n ref={navRef}\n $isActive={isMobileMenuOpen}\n $hasSectionBar={hasSectionBar}\n >\n {result &&\n result.map((item: NavItem, index: number) => {\n return (\n <StyledSidebarList key={index}>\n <StyledSidebarListItem>\n <StyledStrong>\n {item.icon && <Icon name={item.icon} size={16} />}\n {item.label}\n </StyledStrong>{\" \"}\n </StyledSidebarListItem>\n <li>\n <Space $size={20} />\n </li>\n {item.links &&\n item.links.map((link: NavItemLink, indexChild: number) => (\n <SidebarNavLink\n key={indexChild}\n link={link}\n depth={0}\n pathname={pathname}\n onNavigate={() => setIsMobileMenuOpen(false)}\n />\n ))}\n <li aria-hidden=\"true\">\n <Space $size={20} />\n </li>\n </StyledSidebarList>\n );\n })}\n <StyledSidebarFooter ref={footerRef}>\n <Flex $xsJustifyContent=\"flex-start\" $lgJustifyContent=\"flex-end\">\n <ThemeToggle $shortcut />\n </Flex>\n </StyledSidebarFooter>\n </StyledSidebar>\n\n {/* Outside StyledSidebar on purpose: focus mode slides that whole\n column away, and the toggle has to survive it. */}\n <FocusModeToggle />\n </DocsSidebar>\n );\n}\n\nexport { SideBar };\n";
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
StyleMobileBar,
|
|
22
22
|
StyledMobileBurger,
|
|
23
23
|
} from "@/components/layout/DocsComponents";
|
|
24
|
+
import { FocusModeToggle } from "@/components/layout/FocusModeToggle";
|
|
24
25
|
import { Icon } from "@/components/layout/Icon";
|
|
25
26
|
import { useLockBodyScroll } from "@/components/LockBodyScroll";
|
|
26
27
|
|
|
@@ -270,6 +271,10 @@ function SideBar({ result }: SideBarProps) {
|
|
|
270
271
|
</Flex>
|
|
271
272
|
</StyledSidebarFooter>
|
|
272
273
|
</StyledSidebar>
|
|
274
|
+
|
|
275
|
+
{/* Outside StyledSidebar on purpose: focus mode slides that whole
|
|
276
|
+
column away, and the toggle has to survive it. */}
|
|
277
|
+
<FocusModeToggle />
|
|
273
278
|
</DocsSidebar>
|
|
274
279
|
);
|
|
275
280
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const badgeTemplate = "\"use client\";\nimport styled, { css } from \"styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ntype BadgeColor =\n | \"gray\"\n | \"blue\"\n | \"green\"\n | \"yellow\"\n | \"orange\"\n | \"red\"\n | \"purple\"\n | \"white\"\n | \"surface\"\n | \"white-destructive\"\n | \"surface-destructive\"\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"error\";\n\ntype BadgeSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\ntype BadgeShape = \"rounded\" | \"pill\";\n\n// The semantic colors read theme tokens instead of the fixed palette, so\n// they follow theme.json and the light/dark toggle. They are also what the\n// HTTP method chips use.\nconst THEME_TOKEN_COLORS = [\"info\", \"success\", \"warning\", \"error\"] as const;\n\ntype ThemeTokenColor = (typeof THEME_TOKEN_COLORS)[number];\n\ntype HexBadgeColor = Exclude<BadgeColor, ThemeTokenColor>;\n\nfunction isThemeTokenColor(color: BadgeColor): color is ThemeTokenColor {\n return (THEME_TOKEN_COLORS as readonly string[]).includes(color);\n}\n\n// Single source for verb -> badge color, shared by the sidebar method tags\n// and the API playground so every surface colors HTTP verbs identically.\nconst HTTP_METHOD_COLORS: Record<string, BadgeColor> = {\n get: \"info\",\n post: \"success\",\n put: \"warning\",\n patch: \"warning\",\n delete: \"error\",\n head: \"gray\",\n options: \"gray\",\n trace: \"gray\",\n};\n\nfunction httpMethodBadgeColor(method: string): BadgeColor {\n return HTTP_METHOD_COLORS[method.toLowerCase()] ?? \"gray\";\n}\n\ninterface BadgePalette {\n background: string;\n text: string;\n border: string;\n darkBackground: string;\n darkText: string;\n darkBorder: string;\n}\n\n// Strong fills for the hex palette; the white and surface variants have no\n// distinct solid form and fall back to their filled palette.\nconst SOLID_ACCENTS: Partial<Record<HexBadgeColor, string>> = {\n gray: \"#71717a\",\n blue: \"#3b82f6\",\n green: \"#22c55e\",\n yellow: \"#eab308\",\n orange: \"#f97316\",\n red: \"#ef4444\",\n purple: \"#a855f7\",\n};\n\n// Color tints are label-semantic and intentionally independent of theme.json\n// (same rationale as Callout's alert tints); only the surface and semantic\n// token variants read theme tokens, so they follow the active theme on both\n// modes. When both are set, solid wins over stroke.\nfunction badgePalette(\n theme: Theme,\n color: BadgeColor,\n stroke: boolean,\n solid: boolean,\n): BadgePalette {\n if (isThemeTokenColor(color)) {\n const token = theme.colors[color];\n if (solid) {\n return {\n background: token,\n text: theme.colors.surface,\n border: \"transparent\",\n darkBackground: token,\n darkText: theme.colors.surface,\n darkBorder: \"transparent\",\n };\n }\n if (stroke) {\n return {\n background: \"transparent\",\n text: token,\n border: token,\n darkBackground: \"transparent\",\n darkText: token,\n darkBorder: token,\n };\n }\n const tint = `color-mix(in srgb, ${token} 15%, transparent)`;\n return {\n background: tint,\n text: token,\n border: \"transparent\",\n darkBackground: tint,\n darkText: token,\n darkBorder: \"transparent\",\n };\n }\n\n const solidAccent = SOLID_ACCENTS[color];\n if (solid && solidAccent) {\n return {\n background: solidAccent,\n text: \"#ffffff\",\n border: \"transparent\",\n darkBackground: solidAccent,\n darkText: \"#ffffff\",\n darkBorder: \"transparent\",\n };\n }\n\n const surface = {\n background: theme.colors.surface,\n text: theme.colors.grayDark,\n border: theme.colors.grayLight,\n darkBackground: theme.colors.surface,\n darkText: theme.colors.grayDark,\n darkBorder: theme.colors.grayLight,\n };\n\n if (stroke && !solid) {\n const strokes: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"transparent\",\n text: \"#52525b\",\n border: \"#a1a1aa\",\n darkBackground: \"transparent\",\n darkText: \"#d4d4d8\",\n darkBorder: \"#71717a\",\n },\n blue: {\n background: \"transparent\",\n text: \"#1d4ed8\",\n border: \"#3b82f6\",\n darkBackground: \"transparent\",\n darkText: \"#93c5fd\",\n darkBorder: \"#3b82f6\",\n },\n green: {\n background: \"transparent\",\n text: \"#15803d\",\n border: \"#22c55e\",\n darkBackground: \"transparent\",\n darkText: \"#86efac\",\n darkBorder: \"#22c55e\",\n },\n yellow: {\n background: \"transparent\",\n text: \"#a16207\",\n border: \"#eab308\",\n darkBackground: \"transparent\",\n darkText: \"#fde047\",\n darkBorder: \"#eab308\",\n },\n orange: {\n background: \"transparent\",\n text: \"#c2410c\",\n border: \"#f97316\",\n darkBackground: \"transparent\",\n darkText: \"#fdba74\",\n darkBorder: \"#f97316\",\n },\n red: {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n purple: {\n background: \"transparent\",\n text: \"#7e22ce\",\n border: \"#a855f7\",\n darkBackground: \"transparent\",\n darkText: \"#d8b4fe\",\n darkBorder: \"#a855f7\",\n },\n white: {\n background: \"transparent\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"transparent\",\n darkText: \"#fafafa\",\n darkBorder: \"#3f3f46\",\n },\n surface: { ...surface, background: \"transparent\" },\n \"white-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n \"surface-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n };\n return strokes[color];\n }\n\n const filled: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"#f4f4f5\",\n text: \"#3f3f46\",\n border: \"transparent\",\n darkBackground: \"#71717a33\",\n darkText: \"#d4d4d8\",\n darkBorder: \"transparent\",\n },\n blue: {\n background: \"#dbeafe\",\n text: \"#1e40af\",\n border: \"transparent\",\n darkBackground: \"#3b82f633\",\n darkText: \"#93c5fd\",\n darkBorder: \"transparent\",\n },\n green: {\n background: \"#dcfce7\",\n text: \"#166534\",\n border: \"transparent\",\n darkBackground: \"#22c55e33\",\n darkText: \"#86efac\",\n darkBorder: \"transparent\",\n },\n yellow: {\n background: \"#fef9c3\",\n text: \"#854d0e\",\n border: \"transparent\",\n darkBackground: \"#eab30833\",\n darkText: \"#fde047\",\n darkBorder: \"transparent\",\n },\n orange: {\n background: \"#ffedd5\",\n text: \"#9a3412\",\n border: \"transparent\",\n darkBackground: \"#f9731633\",\n darkText: \"#fdba74\",\n darkBorder: \"transparent\",\n },\n red: {\n background: \"#fee2e2\",\n text: \"#991b1b\",\n border: \"transparent\",\n darkBackground: \"#ef444433\",\n darkText: \"#fca5a5\",\n darkBorder: \"transparent\",\n },\n purple: {\n background: \"#f3e8ff\",\n text: \"#6b21a8\",\n border: \"transparent\",\n darkBackground: \"#a855f733\",\n darkText: \"#d8b4fe\",\n darkBorder: \"transparent\",\n },\n white: {\n background: \"#ffffff\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"#ffffff\",\n darkText: \"#18181b\",\n darkBorder: \"#e4e4e7\",\n },\n surface,\n \"white-destructive\": {\n background: \"#ffffff\",\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkBackground: \"#ffffff\",\n darkText: \"#b91c1c\",\n darkBorder: \"#fecaca\",\n },\n \"surface-destructive\": {\n ...surface,\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef44444d\",\n },\n };\n return filled[color];\n}\n\nconst badgeSizes = {\n xs: css`\n font-size: 11px;\n line-height: 16px;\n padding: 1px 6px;\n gap: 3px;\n `,\n sm: css`\n font-size: 12px;\n line-height: 18px;\n padding: 2px 8px;\n gap: 4px;\n `,\n md: css`\n font-size: 13px;\n line-height: 20px;\n padding: 3px 10px;\n gap: 5px;\n `,\n lg: css`\n font-size: 14px;\n line-height: 22px;\n padding: 4px 12px;\n gap: 6px;\n `,\n};\n\nconst badgeIconSizes: Record<BadgeSize, number> = {\n xs: 10,\n sm: 12,\n md: 14,\n lg: 16,\n};\n\nconst StyledBadge = styled.span<{\n theme: Theme;\n $color: BadgeColor;\n $size: BadgeSize;\n $shape: BadgeShape;\n $stroke: boolean;\n $solid: boolean;\n $mono: boolean;\n $disabled: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n vertical-align: middle;\n max-width: max-content;\n font-family: inherit;\n font-weight: 600;\n white-space: nowrap;\n\n & svg.lucide {\n flex-shrink: 0;\n color: inherit;\n }\n\n ${({ $size }) => badgeSizes[$size]}\n\n ${({ theme, $mono }) =>\n $mono &&\n css`\n font-family: ${theme.fonts.mono};\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n `}\n\n ${({ theme, $shape }) =>\n $shape === \"pill\"\n ? css`\n border-radius: 999px;\n `\n : css`\n border-radius: ${theme.spacing.radius.xs};\n `}\n\n ${({ theme, $color, $stroke, $solid }) => {\n const palette = badgePalette(theme, $color, $stroke, $solid);\n return css`\n background: ${palette.background};\n color: ${palette.text};\n border: solid 1px ${palette.border};\n\n :root.dark & {\n background: ${palette.darkBackground};\n color: ${palette.darkText};\n border-color: ${palette.darkBorder};\n }\n `;\n }}\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n opacity: 0.5;\n `}\n`;\n\ninterface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode;\n color?: BadgeColor;\n size?: BadgeSize;\n shape?: BadgeShape;\n icon?: string;\n stroke?: boolean;\n solid?: boolean;\n mono?: boolean;\n disabled?: boolean;\n}\n\nfunction Badge({\n children,\n color = \"gray\",\n size = \"md\",\n shape = \"rounded\",\n icon,\n stroke = false,\n solid = false,\n mono = false,\n disabled = false,\n className,\n}: BadgeProps) {\n return (\n <StyledBadge\n className={className}\n $color={color}\n $size={size}\n $shape={shape}\n $stroke={stroke}\n $solid={solid}\n $mono={mono}\n $disabled={disabled}\n >\n {icon ? <Icon name={icon} size={badgeIconSizes[size]} /> : null}\n {children}\n </StyledBadge>\n );\n}\n\nexport { Badge, httpMethodBadgeColor };\n";
|
|
1
|
+
export declare const badgeTemplate = "\"use client\";\nimport styled, { css } from \"styled-components\";\nimport { Theme } from \"@/app/theme\";\nimport { Icon } from \"@/components/layout/Icon\";\n\ntype BadgeColor =\n | \"gray\"\n | \"blue\"\n | \"green\"\n | \"yellow\"\n | \"orange\"\n | \"red\"\n | \"purple\"\n | \"white\"\n | \"surface\"\n | \"white-destructive\"\n | \"surface-destructive\"\n | \"info\"\n | \"success\"\n | \"warning\"\n | \"error\";\n\ntype BadgeSize = \"xs\" | \"sm\" | \"md\" | \"lg\";\n\ntype BadgeShape = \"rounded\" | \"pill\";\n\n// The semantic colors read theme tokens instead of the fixed palette, so\n// they follow theme.json and the light/dark toggle. They are also what the\n// HTTP method chips use.\nconst THEME_TOKEN_COLORS = [\"info\", \"success\", \"warning\", \"error\"] as const;\n\ntype ThemeTokenColor = (typeof THEME_TOKEN_COLORS)[number];\n\ntype HexBadgeColor = Exclude<BadgeColor, ThemeTokenColor>;\n\nfunction isThemeTokenColor(color: BadgeColor): color is ThemeTokenColor {\n return (THEME_TOKEN_COLORS as readonly string[]).includes(color);\n}\n\n// Single source for verb -> badge color, shared by the sidebar method tags\n// and the API playground so every surface colors HTTP verbs identically.\nconst HTTP_METHOD_COLORS: Record<string, BadgeColor> = {\n get: \"info\",\n post: \"success\",\n put: \"warning\",\n patch: \"warning\",\n delete: \"error\",\n head: \"gray\",\n options: \"gray\",\n trace: \"gray\",\n};\n\nfunction httpMethodBadgeColor(method: string): BadgeColor {\n return HTTP_METHOD_COLORS[method.toLowerCase()] ?? \"gray\";\n}\n\ninterface BadgePalette {\n background: string;\n text: string;\n border: string;\n darkBackground: string;\n darkText: string;\n darkBorder: string;\n}\n\n// Strong fills for the hex palette; the white and surface variants have no\n// distinct solid form and fall back to their filled palette.\nconst SOLID_ACCENTS: Partial<Record<HexBadgeColor, string>> = {\n gray: \"#71717a\",\n blue: \"#3b82f6\",\n green: \"#22c55e\",\n yellow: \"#eab308\",\n orange: \"#f97316\",\n red: \"#ef4444\",\n purple: \"#a855f7\",\n};\n\n// Color tints are label-semantic and intentionally independent of theme.json\n// (same rationale as Callout's alert tints); only the surface and semantic\n// token variants read theme tokens, so they follow the active theme on both\n// modes. When both are set, solid wins over stroke.\nfunction badgePalette(\n theme: Theme,\n color: BadgeColor,\n stroke: boolean,\n solid: boolean,\n): BadgePalette {\n if (isThemeTokenColor(color)) {\n const token = theme.colors[color];\n if (solid) {\n return {\n background: token,\n text: theme.colors.surface,\n border: \"transparent\",\n darkBackground: token,\n darkText: theme.colors.surface,\n darkBorder: \"transparent\",\n };\n }\n if (stroke) {\n return {\n background: \"transparent\",\n text: token,\n border: token,\n darkBackground: \"transparent\",\n darkText: token,\n darkBorder: token,\n };\n }\n const tint = `color-mix(in srgb, ${token} 15%, transparent)`;\n return {\n background: tint,\n text: token,\n border: \"transparent\",\n darkBackground: tint,\n darkText: token,\n darkBorder: \"transparent\",\n };\n }\n\n const solidAccent = SOLID_ACCENTS[color];\n if (solid && solidAccent) {\n return {\n background: solidAccent,\n text: \"#ffffff\",\n border: \"transparent\",\n darkBackground: solidAccent,\n darkText: \"#ffffff\",\n darkBorder: \"transparent\",\n };\n }\n\n // The \"surface\" variants sit on the page surface of the active theme: white\n // on light, black on dark. They read theme.colors.light (the html/body\n // background) rather than theme.colors.surface \u2014 that token is a foreground\n // color that stays white in both modes, so using it here left the chip white\n // on dark pages. The \"white\" variants below stay literally white by contract.\n const surface = {\n background: theme.colors.light,\n text: theme.colors.grayDark,\n border: theme.colors.grayLight,\n darkBackground: theme.colors.light,\n darkText: theme.colors.grayDark,\n darkBorder: theme.colors.gray,\n };\n\n if (stroke && !solid) {\n const strokes: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"transparent\",\n text: \"#52525b\",\n border: \"#a1a1aa\",\n darkBackground: \"transparent\",\n darkText: \"#d4d4d8\",\n darkBorder: \"#71717a\",\n },\n blue: {\n background: \"transparent\",\n text: \"#1d4ed8\",\n border: \"#3b82f6\",\n darkBackground: \"transparent\",\n darkText: \"#93c5fd\",\n darkBorder: \"#3b82f6\",\n },\n green: {\n background: \"transparent\",\n text: \"#15803d\",\n border: \"#22c55e\",\n darkBackground: \"transparent\",\n darkText: \"#86efac\",\n darkBorder: \"#22c55e\",\n },\n yellow: {\n background: \"transparent\",\n text: \"#a16207\",\n border: \"#eab308\",\n darkBackground: \"transparent\",\n darkText: \"#fde047\",\n darkBorder: \"#eab308\",\n },\n orange: {\n background: \"transparent\",\n text: \"#c2410c\",\n border: \"#f97316\",\n darkBackground: \"transparent\",\n darkText: \"#fdba74\",\n darkBorder: \"#f97316\",\n },\n red: {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n purple: {\n background: \"transparent\",\n text: \"#7e22ce\",\n border: \"#a855f7\",\n darkBackground: \"transparent\",\n darkText: \"#d8b4fe\",\n darkBorder: \"#a855f7\",\n },\n white: {\n background: \"transparent\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"transparent\",\n darkText: \"#fafafa\",\n darkBorder: \"#3f3f46\",\n },\n surface: {\n ...surface,\n background: \"transparent\",\n darkBackground: \"transparent\",\n },\n \"white-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n \"surface-destructive\": {\n background: \"transparent\",\n text: \"#b91c1c\",\n border: \"#ef4444\",\n darkBackground: \"transparent\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef4444\",\n },\n };\n return strokes[color];\n }\n\n const filled: Record<HexBadgeColor, BadgePalette> = {\n gray: {\n background: \"#f4f4f5\",\n text: \"#3f3f46\",\n border: \"transparent\",\n darkBackground: \"#71717a33\",\n darkText: \"#d4d4d8\",\n darkBorder: \"transparent\",\n },\n blue: {\n background: \"#dbeafe\",\n text: \"#1e40af\",\n border: \"transparent\",\n darkBackground: \"#3b82f633\",\n darkText: \"#93c5fd\",\n darkBorder: \"transparent\",\n },\n green: {\n background: \"#dcfce7\",\n text: \"#166534\",\n border: \"transparent\",\n darkBackground: \"#22c55e33\",\n darkText: \"#86efac\",\n darkBorder: \"transparent\",\n },\n yellow: {\n background: \"#fef9c3\",\n text: \"#854d0e\",\n border: \"transparent\",\n darkBackground: \"#eab30833\",\n darkText: \"#fde047\",\n darkBorder: \"transparent\",\n },\n orange: {\n background: \"#ffedd5\",\n text: \"#9a3412\",\n border: \"transparent\",\n darkBackground: \"#f9731633\",\n darkText: \"#fdba74\",\n darkBorder: \"transparent\",\n },\n red: {\n background: \"#fee2e2\",\n text: \"#991b1b\",\n border: \"transparent\",\n darkBackground: \"#ef444433\",\n darkText: \"#fca5a5\",\n darkBorder: \"transparent\",\n },\n purple: {\n background: \"#f3e8ff\",\n text: \"#6b21a8\",\n border: \"transparent\",\n darkBackground: \"#a855f733\",\n darkText: \"#d8b4fe\",\n darkBorder: \"transparent\",\n },\n // Literally white in both modes, so it stays legible on images, colored\n // frames, and hero areas. Use the surface variants for theme-aware chips.\n white: {\n background: \"#ffffff\",\n text: \"#18181b\",\n border: \"#e4e4e7\",\n darkBackground: \"#ffffff\",\n darkText: \"#18181b\",\n darkBorder: \"#e4e4e7\",\n },\n surface,\n \"white-destructive\": {\n background: \"#ffffff\",\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkBackground: \"#ffffff\",\n darkText: \"#b91c1c\",\n darkBorder: \"#fecaca\",\n },\n \"surface-destructive\": {\n ...surface,\n text: \"#b91c1c\",\n border: \"#fecaca\",\n darkText: \"#fca5a5\",\n darkBorder: \"#ef444466\",\n },\n };\n return filled[color];\n}\n\nconst badgeSizes = {\n xs: css`\n font-size: 11px;\n line-height: 16px;\n padding: 1px 6px;\n gap: 3px;\n `,\n sm: css`\n font-size: 12px;\n line-height: 18px;\n padding: 2px 8px;\n gap: 4px;\n `,\n md: css`\n font-size: 13px;\n line-height: 20px;\n padding: 3px 10px;\n gap: 5px;\n `,\n lg: css`\n font-size: 14px;\n line-height: 22px;\n padding: 4px 12px;\n gap: 6px;\n `,\n};\n\nconst badgeIconSizes: Record<BadgeSize, number> = {\n xs: 10,\n sm: 12,\n md: 14,\n lg: 16,\n};\n\nconst StyledBadge = styled.span<{\n theme: Theme;\n $color: BadgeColor;\n $size: BadgeSize;\n $shape: BadgeShape;\n $stroke: boolean;\n $solid: boolean;\n $mono: boolean;\n $disabled: boolean;\n}>`\n display: inline-flex;\n align-items: center;\n vertical-align: middle;\n max-width: max-content;\n font-family: inherit;\n font-weight: 600;\n white-space: nowrap;\n\n & svg.lucide {\n flex-shrink: 0;\n color: inherit;\n }\n\n ${({ $size }) => badgeSizes[$size]}\n\n ${({ theme, $mono }) =>\n $mono &&\n css`\n font-family: ${theme.fonts.mono};\n font-weight: 700;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n `}\n\n ${({ theme, $shape }) =>\n $shape === \"pill\"\n ? css`\n border-radius: 999px;\n `\n : css`\n border-radius: ${theme.spacing.radius.xs};\n `}\n\n ${({ theme, $color, $stroke, $solid }) => {\n const palette = badgePalette(theme, $color, $stroke, $solid);\n return css`\n background: ${palette.background};\n color: ${palette.text};\n border: solid 1px ${palette.border};\n\n :root.dark & {\n background: ${palette.darkBackground};\n color: ${palette.darkText};\n border-color: ${palette.darkBorder};\n }\n `;\n }}\n\n ${({ $disabled }) =>\n $disabled &&\n css`\n opacity: 0.5;\n `}\n`;\n\ninterface BadgeProps extends React.HTMLAttributes<HTMLSpanElement> {\n children: React.ReactNode;\n color?: BadgeColor;\n size?: BadgeSize;\n shape?: BadgeShape;\n icon?: string;\n stroke?: boolean;\n solid?: boolean;\n mono?: boolean;\n disabled?: boolean;\n}\n\nfunction Badge({\n children,\n color = \"gray\",\n size = \"md\",\n shape = \"rounded\",\n icon,\n stroke = false,\n solid = false,\n mono = false,\n disabled = false,\n className,\n}: BadgeProps) {\n return (\n <StyledBadge\n className={className}\n $color={color}\n $size={size}\n $shape={shape}\n $stroke={stroke}\n $solid={solid}\n $mono={mono}\n $disabled={disabled}\n >\n {icon ? <Icon name={icon} size={badgeIconSizes[size]} /> : null}\n {children}\n </StyledBadge>\n );\n}\n\nexport { Badge, httpMethodBadgeColor };\n";
|
|
@@ -130,13 +130,18 @@ function badgePalette(
|
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
132
|
|
|
133
|
+
// The "surface" variants sit on the page surface of the active theme: white
|
|
134
|
+
// on light, black on dark. They read theme.colors.light (the html/body
|
|
135
|
+
// background) rather than theme.colors.surface — that token is a foreground
|
|
136
|
+
// color that stays white in both modes, so using it here left the chip white
|
|
137
|
+
// on dark pages. The "white" variants below stay literally white by contract.
|
|
133
138
|
const surface = {
|
|
134
|
-
background: theme.colors.
|
|
139
|
+
background: theme.colors.light,
|
|
135
140
|
text: theme.colors.grayDark,
|
|
136
141
|
border: theme.colors.grayLight,
|
|
137
|
-
darkBackground: theme.colors.
|
|
142
|
+
darkBackground: theme.colors.light,
|
|
138
143
|
darkText: theme.colors.grayDark,
|
|
139
|
-
darkBorder: theme.colors.
|
|
144
|
+
darkBorder: theme.colors.gray,
|
|
140
145
|
};
|
|
141
146
|
|
|
142
147
|
if (stroke && !solid) {
|
|
@@ -205,7 +210,11 @@ function badgePalette(
|
|
|
205
210
|
darkText: "#fafafa",
|
|
206
211
|
darkBorder: "#3f3f46",
|
|
207
212
|
},
|
|
208
|
-
surface: {
|
|
213
|
+
surface: {
|
|
214
|
+
...surface,
|
|
215
|
+
background: "transparent",
|
|
216
|
+
darkBackground: "transparent",
|
|
217
|
+
},
|
|
209
218
|
"white-destructive": {
|
|
210
219
|
background: "transparent",
|
|
211
220
|
text: "#b91c1c",
|
|
@@ -283,6 +292,8 @@ function badgePalette(
|
|
|
283
292
|
darkText: "#d8b4fe",
|
|
284
293
|
darkBorder: "transparent",
|
|
285
294
|
},
|
|
295
|
+
// Literally white in both modes, so it stays legible on images, colored
|
|
296
|
+
// frames, and hero areas. Use the surface variants for theme-aware chips.
|
|
286
297
|
white: {
|
|
287
298
|
background: "#ffffff",
|
|
288
299
|
text: "#18181b",
|
|
@@ -305,7 +316,7 @@ function badgePalette(
|
|
|
305
316
|
text: "#b91c1c",
|
|
306
317
|
border: "#fecaca",
|
|
307
318
|
darkText: "#fca5a5",
|
|
308
|
-
darkBorder: "#
|
|
319
|
+
darkBorder: "#ef444466",
|
|
309
320
|
},
|
|
310
321
|
};
|
|
311
322
|
return filled[color];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const docsComponentsTemplate = "\"use client\";\nimport React, { createContext, useContext } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n resetButton,\n styledSmall,\n styledStrong,\n styledText,\n} from \"cherry-styled-components\";\nimport Link from \"next/link\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n styledAnchor,\n styledTable,\n stylesLists,\n} from \"@/components/layout/SharedStyled\";\nimport { Badge } from \"@/components/layout/Badge\";\nimport { ChatContext } from \"@/components/Chat\";\n\nconst SectionBarContext = createContext(false);\n\nfunction SectionBarProvider({\n hasSectionBar,\n children,\n}: {\n hasSectionBar: boolean;\n children: React.ReactNode;\n}) {\n return (\n <SectionBarContext.Provider value={hasSectionBar}>\n {children}\n </SectionBarContext.Provider>\n );\n}\n\ninterface DocsProps {\n children: React.ReactNode;\n}\n\nconst StyledDocsWrapper = styled.main<{ theme: Theme }>`\n position: relative;\n`;\n\nconst StyledDocsSidebar = styled.div<{ theme: Theme }>`\n clear: both;\n`;\n\nconst StyledDocsContainer = styled.div<{ theme: Theme; $isChatOpen?: boolean }>`\n position: relative;\n padding: 0 20px 100px 20px;\n width: 100%;\n ${({ theme }) => styledText(theme)};\n transition: all 0.3s ease;\n\n ${mq(\"lg\")} {\n padding: 0 300px 80px 300px;\n\n ${({ $isChatOpen }) =>\n $isChatOpen &&\n css`\n padding: 0 440px 80px 300px;\n `}\n }\n\n & p {\n color: ${({ theme }) => theme.colors.grayDark};\n hyphens: auto;\n }\n\n & pre {\n max-width: 100%;\n }\n\n ${styledAnchor};\n ${stylesLists};\n ${styledTable};\n\n & img,\n & video,\n & iframe {\n max-width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n\n & code:not([class]),\n & kbd {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.dark};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n overflow-wrap: anywhere;\n }\n\n & .lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n\n & .aspect-video {\n aspect-ratio: 16 / 9;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n`;\n\nexport const StyledMarkdownContainer = styled.div`\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex: 1;\n max-width: 640px;\n margin: auto;\n`;\n\ninterface Props {\n theme?: Theme;\n $isActive?: boolean;\n $isOpen?: boolean;\n $hasSectionBar?: boolean;\n}\n\nexport const StyledSidebar = styled.nav<Props>`\n position: fixed;\n overflow-y: auto;\n max-height: calc(\n 100dvh - ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px\n );\n width: 100%;\n z-index: 99;\n top: ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px;\n height: 100%;\n padding: 20px;\n opacity: 0;\n pointer-events: none;\n transition: all 0.3s ease;\n transform: translateY(30px);\n left: 0;\n background: ${({ theme }) => theme.colors.light};\n -webkit-overflow-scrolling: touch;\n display: flex;\n flex-direction: column;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n border-right: solid 1px ${({ theme }) => theme.colors.grayLight};\n transition: none;\n max-height: 100dvh;\n width: 220px;\n background: transparent;\n padding: 82px 20px 20px 20px;\n opacity: 1;\n pointer-events: all;\n transform: translateY(0);\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n top: 0;\n width: 280px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n transform: translateY(0);\n opacity: 1;\n pointer-events: all;\n `}\n`;\n\nexport const StyledSidebarFooter = styled.div`\n padding: 22px 20px;\n position: sticky;\n border-top: 1px solid ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n margin: 0 -20px -20px;\n bottom: -20px;\n backdrop-filter: blur(10px);\n\n ${mq(\"lg\")} {\n padding: 16px 20px;\n }\n`;\n\nexport const StyledIndexSidebar = styled.ul<{ theme: Theme }>`\n display: none;\n list-style: none;\n margin: 0;\n padding: 0;\n position: fixed;\n top: 0;\n right: 0;\n width: 280px;\n height: 100dvh;\n overflow-y: auto;\n z-index: 1;\n padding: 82px 20px 20px 20px;\n background: ${({ theme }) => theme.colors.light};\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n -webkit-overflow-scrolling: touch;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n display: block;\n }\n\n & li {\n padding: 5px 0;\n }\n`;\n\nexport const StyledIndexSidebarLabel = styled.span<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nexport const StyledIndexSidebarLi = styled.li<{\n theme: Theme;\n $isActive: boolean;\n}>`\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n left: 0;\n height: 20px;\n width: 1px;\n background: transparent;\n transition: all 0.3s ease;\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n &::before {\n background: ${theme.colors.primary};\n }\n `}\n`;\n\nexport const StyledIndexSidebarLink = styled.a<{\n theme: Theme;\n $isActive: boolean;\n}>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : theme.colors.dark};\n font-weight: ${({ $isActive }) => ($isActive ? \"600\" : \"400\")};\n text-decoration: none;\n transition: all 0.3s ease;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nexport const StyledSidebarList = styled.ul`\n list-style: none;\n margin: 0;\n padding: 0;\n\n &:last-of-type {\n margin-bottom: auto;\n }\n`;\n\nexport const StyledStrong = styled.strong<{ theme: Theme }>`\n font-weight: 600;\n ${({ theme }) => styledStrong(theme)};\n color: ${({ theme }) => theme.colors.accentStrong};\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n & svg {\n flex-shrink: 0;\n }\n`;\n\nexport const StyledSidebarListItem = styled.li`\n display: flex;\n gap: 10px;\n clear: both;\n`;\n\n// Shared appearance for every sidebar row - leaf links AND nested group\n// headers - so hover, active state, and the left rail read identically.\nconst sidebarRowStyles = css<Props>`\n text-decoration: none;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n line-height: 1.6;\n color: ${({ theme }) => theme.colors.accentMuted};\n padding: 5px 0 5px 20px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n transition: all 0.3s ease;\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n\n & svg {\n flex-shrink: 0;\n }\n\n &:hover {\n color: ${({ theme }) => theme.colors.accent};\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n color: ${theme.colors.accentStrong};\n border-color: ${theme.colors.primary};\n font-weight: 600;\n `};\n`;\n\n// The collapse chevron points right when closed and rotates to point down\n// when the group is open.\nconst sidebarChevron = css<Props>`\n & .lucide-chevron-right {\n margin-left: auto;\n transition: transform 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n transform: rotate(90deg);\n `}\n }\n`;\n\nexport const StyledSidebarListItemLink = styled(Link)<Props>`\n ${sidebarRowStyles};\n`;\n\n// Compact HTTP-method label shown before a generated API endpoint link, colored\n// by verb so endpoints are scannable in the sidebar. Only rendered when a link\n// carries an `httpMethod` (endpoint pages do; hand-written pages do not).\n// The look is Badge's mono variation (tinted, solid when active); only\n// sidebar metrics are adjusted here.\nexport const StyledSidebarMethodTag = styled(Badge)`\n flex-shrink: 0;\n font-size: 9px;\n letter-spacing: 0.02em;\n padding: 1px 4px;\n border: none;\n`;\n\n// Nested navigation group. The header shares the link appearance/hover; a\n// non-navigable group is a single toggle button, while a group that is also a\n// page pairs a link with a chevron toggle. Children live in\n// StyledSidebarGroupContent, which animates open/closed via height 0 <-> auto\n// (enabled by interpolate-size in GlobalStyles, same as the Accordion).\nexport const StyledSidebarGroupButton = styled.button<Props>`\n ${resetButton};\n ${sidebarRowStyles};\n ${sidebarChevron};\n width: 100%;\n text-align: left;\n\n /* Buttons aren't covered by the global a:focus-visible ring, so this\n nav-row toggle carries its own copy of it. */\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupRow = styled.div<Props>`\n ${sidebarRowStyles};\n ${sidebarChevron};\n\n /* The row is a plain div, so it never matches :focus-visible itself. Ring the\n whole row when its inner link or chevron takes keyboard focus instead, to\n match the leaf-row focus treatment. */\n &:has(:focus-visible) {\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupLink = styled(Link)`\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n color: inherit;\n text-decoration: none;\n\n & svg {\n flex-shrink: 0;\n }\n\n /* Ring is drawn on the parent row via :has(:focus-visible); suppress the\n global a:focus-visible glow so it isn't drawn twice. */\n &:focus-visible {\n outline: none;\n box-shadow: none;\n }\n`;\n\nexport const StyledSidebarGroupChevron = styled.button`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n cursor: pointer;\n\n /* Ring is drawn on the parent row via :has(:focus-visible). */\n &:focus-visible {\n outline: none;\n }\n`;\n\nexport const StyledSidebarGroupContent = styled.ul<Props>`\n list-style: none;\n margin: 0;\n padding: 0;\n height: 0;\n overflow: clip;\n transition: all 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n height: auto;\n `}\n`;\n\nexport const StyleMobileBar = styled.button<Props>`\n ${resetButton};\n position: fixed;\n z-index: 999;\n bottom: 0;\n right: 20px;\n font-size: ${({ theme }) => theme.fontSizes.strong.lg};\n line-height: ${({ theme }) => theme.fontSizes.strong.lg};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.surface};\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n padding: 10px;\n border-radius: 100px;\n margin: 0 0 20px 0;\n font-weight: 600;\n display: flex;\n justify-content: flex-start;\n width: auto;\n\n ${mq(\"lg\")} {\n display: none;\n }\n\n ${({ $isActive }) => $isActive && `position: fixed;`};\n`;\n\nexport const StyledMobileBurger = styled.span<Props>`\n display: block;\n margin: auto 0;\n width: 18px;\n height: 18px;\n position: relative;\n overflow: hidden;\n background: transparent;\n position: relative;\n transform: scale(0.8);\n\n &::before,\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n width: 18px;\n height: 3px;\n border-radius: 3px;\n background: ${({ theme }) => theme.colors.surface};\n transition: all 0.3s ease;\n }\n\n &::before {\n top: 3px;\n }\n\n &::after {\n bottom: 3px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n &::before {\n transform: translateY(5px) rotate(45deg);\n }\n\n &::after {\n transform: translateY(-4px) rotate(-45deg);\n }\n `};\n`;\n\nexport const StyledMissingComponent = styled.div`\n background: ${({ theme }) => theme.colors.error};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n color: ${({ theme }) => theme.colors.surface};\n font-weight: 600;\n display: flex;\n gap: 10px;\n align-items: center;\n`;\n\ninterface DocsWrapperProps {\n children: React.ReactNode;\n}\n\nfunction DocsWrapper({ children }: DocsWrapperProps) {\n return <StyledDocsWrapper>{children}</StyledDocsWrapper>;\n}\n\nfunction DocsSidebar({ children }: DocsProps) {\n return <StyledDocsSidebar>{children}</StyledDocsSidebar>;\n}\n\nfunction DocsContainer({ children }: DocsProps) {\n const { isOpen } = useContext(ChatContext);\n\n return (\n <StyledDocsContainer $isChatOpen={isOpen}>{children}</StyledDocsContainer>\n );\n}\n\nexport {\n DocsWrapper,\n DocsSidebar,\n DocsContainer,\n SectionBarContext,\n SectionBarProvider,\n};\n";
|
|
1
|
+
export declare const docsComponentsTemplate = "\"use client\";\nimport React, { createContext, useContext } from \"react\";\nimport styled, { css } from \"styled-components\";\nimport {\n resetButton,\n styledSmall,\n styledStrong,\n styledText,\n} from \"cherry-styled-components\";\nimport Link from \"next/link\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n focusModeColumn,\n focusModeHide,\n sidePanelOffset,\n styledAnchor,\n styledTable,\n stylesLists,\n} from \"@/components/layout/SharedStyled\";\nimport { Badge } from \"@/components/layout/Badge\";\nimport { ChatContext } from \"@/components/Chat\";\n\nconst SectionBarContext = createContext(false);\n\nfunction SectionBarProvider({\n hasSectionBar,\n children,\n}: {\n hasSectionBar: boolean;\n children: React.ReactNode;\n}) {\n return (\n <SectionBarContext.Provider value={hasSectionBar}>\n {children}\n </SectionBarContext.Provider>\n );\n}\n\ninterface DocsProps {\n children: React.ReactNode;\n}\n\nconst StyledDocsWrapper = styled.main<{ theme: Theme }>`\n position: relative;\n`;\n\nconst StyledDocsSidebar = styled.div<{ theme: Theme }>`\n clear: both;\n`;\n\nconst StyledDocsContainer = styled.div<{ theme: Theme; $isChatOpen?: boolean }>`\n position: relative;\n padding: 0 20px 100px 20px;\n width: 100%;\n ${({ theme }) => styledText(theme)};\n transition: all 0.3s ease;\n\n ${mq(\"lg\")} {\n padding: 0 300px 80px 300px;\n\n ${({ $isChatOpen }) =>\n $isChatOpen &&\n css`\n padding: 0 440px 80px 300px;\n `}\n }\n\n ${sidePanelOffset};\n ${({ $isChatOpen }) => !$isChatOpen && focusModeColumn};\n\n & p {\n color: ${({ theme }) => theme.colors.grayDark};\n hyphens: auto;\n }\n\n & pre {\n max-width: 100%;\n }\n\n ${styledAnchor};\n ${stylesLists};\n ${styledTable};\n\n & img,\n & video,\n & iframe {\n max-width: 100%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n\n & code:not([class]),\n & kbd {\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 20%, transparent)`};\n color: ${({ theme }) => theme.colors.dark};\n padding: 2px 4px;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n overflow-wrap: anywhere;\n }\n\n & .lucide {\n color: ${({ theme }) => theme.colors.primary};\n }\n\n & .aspect-video {\n aspect-ratio: 16 / 9;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n }\n`;\n\nexport const StyledMarkdownContainer = styled.div`\n display: flex;\n flex-direction: column;\n gap: 20px;\n flex: 1;\n max-width: 640px;\n margin: auto;\n`;\n\ninterface Props {\n theme?: Theme;\n $isActive?: boolean;\n $isOpen?: boolean;\n $hasSectionBar?: boolean;\n}\n\nexport const StyledSidebar = styled.nav<Props>`\n position: fixed;\n overflow-y: auto;\n max-height: calc(\n 100dvh - ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px\n );\n width: 100%;\n z-index: 99;\n top: ${({ $hasSectionBar }) => ($hasSectionBar ? 104 : 62)}px;\n height: 100%;\n padding: 20px;\n opacity: 0;\n pointer-events: none;\n transition: all 0.3s ease;\n transform: translateY(30px);\n left: 0;\n background: ${({ theme }) => theme.colors.light};\n -webkit-overflow-scrolling: touch;\n display: flex;\n flex-direction: column;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n border-right: solid 1px ${({ theme }) => theme.colors.grayLight};\n transition: none;\n max-height: 100dvh;\n width: 220px;\n background: transparent;\n padding: 82px 20px 20px 20px;\n opacity: 1;\n pointer-events: all;\n transform: translateY(0);\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n top: 0;\n width: 280px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n transform: translateY(0);\n opacity: 1;\n pointer-events: all;\n `}\n\n ${focusModeHide(\"left\")};\n`;\n\nexport const StyledSidebarFooter = styled.div`\n padding: 22px 20px;\n position: sticky;\n border-top: 1px solid ${({ theme }) => theme.colors.grayLight};\n background: ${({ theme }) =>\n `color-mix(in srgb, ${theme.colors.primaryLight} 5%, transparent)`};\n margin: 0 -20px -20px;\n bottom: -20px;\n backdrop-filter: blur(10px);\n\n ${mq(\"lg\")} {\n padding: 16px 20px;\n }\n`;\n\nexport const StyledIndexSidebar = styled.ul<{ theme: Theme }>`\n display: none;\n list-style: none;\n margin: 0;\n padding: 0;\n position: fixed;\n top: 0;\n right: 0;\n width: 280px;\n height: 100dvh;\n overflow-y: auto;\n z-index: 1;\n padding: 82px 20px 20px 20px;\n background: ${({ theme }) => theme.colors.light};\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n -webkit-overflow-scrolling: touch;\n\n &::-webkit-scrollbar {\n display: none;\n }\n\n ${mq(\"lg\")} {\n display: block;\n }\n\n & li {\n padding: 5px 0;\n }\n\n ${focusModeHide(\"right\")};\n`;\n\nexport const StyledIndexSidebarLabel = styled.span<{ theme: Theme }>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme }) => theme.colors.grayDark};\n`;\n\nexport const StyledIndexSidebarLi = styled.li<{\n theme: Theme;\n $isActive: boolean;\n}>`\n &::before {\n content: \"\";\n display: block;\n position: absolute;\n left: 0;\n height: 20px;\n width: 1px;\n background: transparent;\n transition: all 0.3s ease;\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n &::before {\n background: ${theme.colors.primary};\n }\n `}\n`;\n\nexport const StyledIndexSidebarLink = styled.a<{\n theme: Theme;\n $isActive: boolean;\n}>`\n ${({ theme }) => styledSmall(theme)};\n color: ${({ theme, $isActive }) =>\n $isActive ? theme.colors.primary : theme.colors.dark};\n font-weight: ${({ $isActive }) => ($isActive ? \"600\" : \"400\")};\n text-decoration: none;\n transition: all 0.3s ease;\n\n &:hover {\n color: ${({ theme }) => theme.colors.primary};\n }\n`;\n\nexport const StyledSidebarList = styled.ul`\n list-style: none;\n margin: 0;\n padding: 0;\n\n &:last-of-type {\n margin-bottom: auto;\n }\n`;\n\nexport const StyledStrong = styled.strong<{ theme: Theme }>`\n font-weight: 600;\n ${({ theme }) => styledStrong(theme)};\n color: ${({ theme }) => theme.colors.accentStrong};\n display: inline-flex;\n align-items: center;\n gap: 8px;\n\n & svg {\n flex-shrink: 0;\n }\n`;\n\nexport const StyledSidebarListItem = styled.li`\n display: flex;\n gap: 10px;\n clear: both;\n`;\n\n// Shared appearance for every sidebar row - leaf links AND nested group\n// headers - so hover, active state, and the left rail read identically.\nconst sidebarRowStyles = css<Props>`\n text-decoration: none;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n line-height: 1.6;\n color: ${({ theme }) => theme.colors.accentMuted};\n padding: 5px 0 5px 20px;\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n transition: all 0.3s ease;\n border-left: solid 1px ${({ theme }) => theme.colors.grayLight};\n\n & svg {\n flex-shrink: 0;\n }\n\n &:hover {\n color: ${({ theme }) => theme.colors.accent};\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n ${({ $isActive, theme }) =>\n $isActive &&\n css`\n color: ${theme.colors.accentStrong};\n border-color: ${theme.colors.primary};\n font-weight: 600;\n `};\n`;\n\n// The collapse chevron points right when closed and rotates to point down\n// when the group is open.\nconst sidebarChevron = css<Props>`\n & .lucide-chevron-right {\n margin-left: auto;\n transition: transform 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n transform: rotate(90deg);\n `}\n }\n`;\n\nexport const StyledSidebarListItemLink = styled(Link)<Props>`\n ${sidebarRowStyles};\n`;\n\n// Compact HTTP-method label shown before a generated API endpoint link, colored\n// by verb so endpoints are scannable in the sidebar. Only rendered when a link\n// carries an `httpMethod` (endpoint pages do; hand-written pages do not).\n// The look is Badge's mono variation (tinted, solid when active); only\n// sidebar metrics are adjusted here.\nexport const StyledSidebarMethodTag = styled(Badge)`\n flex-shrink: 0;\n font-size: 9px;\n letter-spacing: 0.02em;\n padding: 1px 4px;\n border: none;\n`;\n\n// Nested navigation group. The header shares the link appearance/hover; a\n// non-navigable group is a single toggle button, while a group that is also a\n// page pairs a link with a chevron toggle. Children live in\n// StyledSidebarGroupContent, which animates open/closed via height 0 <-> auto\n// (enabled by interpolate-size in GlobalStyles, same as the Accordion).\nexport const StyledSidebarGroupButton = styled.button<Props>`\n ${resetButton};\n ${sidebarRowStyles};\n ${sidebarChevron};\n width: 100%;\n text-align: left;\n\n /* Buttons aren't covered by the global a:focus-visible ring, so this\n nav-row toggle carries its own copy of it. */\n &:focus-visible {\n outline: none;\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupRow = styled.div<Props>`\n ${sidebarRowStyles};\n ${sidebarChevron};\n\n /* The row is a plain div, so it never matches :focus-visible itself. Ring the\n whole row when its inner link or chevron takes keyboard focus instead, to\n match the leaf-row focus treatment. */\n &:has(:focus-visible) {\n border-radius: ${({ theme }) => theme.spacing.radius.xs};\n box-shadow: 0 0 0 2px ${({ theme }) => theme.colors.primaryLight};\n }\n`;\n\nexport const StyledSidebarGroupLink = styled(Link)`\n display: flex;\n align-items: center;\n gap: 8px;\n flex: 1;\n min-width: 0;\n color: inherit;\n text-decoration: none;\n\n & svg {\n flex-shrink: 0;\n }\n\n /* Ring is drawn on the parent row via :has(:focus-visible); suppress the\n global a:focus-visible glow so it isn't drawn twice. */\n &:focus-visible {\n outline: none;\n box-shadow: none;\n }\n`;\n\nexport const StyledSidebarGroupChevron = styled.button`\n display: inline-flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n padding: 0;\n border: 0;\n background: none;\n color: inherit;\n cursor: pointer;\n\n /* Ring is drawn on the parent row via :has(:focus-visible). */\n &:focus-visible {\n outline: none;\n }\n`;\n\nexport const StyledSidebarGroupContent = styled.ul<Props>`\n list-style: none;\n margin: 0;\n padding: 0;\n height: 0;\n overflow: clip;\n transition: all 0.3s ease;\n\n ${({ $isOpen }) =>\n $isOpen &&\n css`\n height: auto;\n `}\n`;\n\nexport const StyleMobileBar = styled.button<Props>`\n ${resetButton};\n position: fixed;\n z-index: 999;\n bottom: 0;\n right: 20px;\n font-size: ${({ theme }) => theme.fontSizes.strong.lg};\n line-height: ${({ theme }) => theme.fontSizes.strong.lg};\n box-shadow: ${({ theme }) => theme.shadows.sm};\n background: ${({ theme }) => theme.colors.primary};\n color: ${({ theme }) => theme.colors.surface};\n backdrop-filter: blur(10px);\n -webkit-backdrop-filter: blur(10px);\n padding: 10px;\n border-radius: 100px;\n margin: 0 0 20px 0;\n font-weight: 600;\n display: flex;\n justify-content: flex-start;\n width: auto;\n\n ${mq(\"lg\")} {\n display: none;\n }\n\n ${({ $isActive }) => $isActive && `position: fixed;`};\n`;\n\nexport const StyledMobileBurger = styled.span<Props>`\n display: block;\n margin: auto 0;\n width: 18px;\n height: 18px;\n position: relative;\n overflow: hidden;\n background: transparent;\n position: relative;\n transform: scale(0.8);\n\n &::before,\n &::after {\n content: \"\";\n display: block;\n position: absolute;\n width: 18px;\n height: 3px;\n border-radius: 3px;\n background: ${({ theme }) => theme.colors.surface};\n transition: all 0.3s ease;\n }\n\n &::before {\n top: 3px;\n }\n\n &::after {\n bottom: 3px;\n }\n\n ${({ $isActive }) =>\n $isActive &&\n css`\n &::before {\n transform: translateY(5px) rotate(45deg);\n }\n\n &::after {\n transform: translateY(-4px) rotate(-45deg);\n }\n `};\n`;\n\nexport const StyledMissingComponent = styled.div`\n background: ${({ theme }) => theme.colors.error};\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n padding: 20px;\n font-size: ${({ theme }) => theme.fontSizes.small.lg};\n color: ${({ theme }) => theme.colors.surface};\n font-weight: 600;\n display: flex;\n gap: 10px;\n align-items: center;\n`;\n\ninterface DocsWrapperProps {\n children: React.ReactNode;\n}\n\nfunction DocsWrapper({ children }: DocsWrapperProps) {\n return <StyledDocsWrapper>{children}</StyledDocsWrapper>;\n}\n\nfunction DocsSidebar({ children }: DocsProps) {\n return <StyledDocsSidebar>{children}</StyledDocsSidebar>;\n}\n\nfunction DocsContainer({ children }: DocsProps) {\n const { isOpen } = useContext(ChatContext);\n\n return (\n <StyledDocsContainer $isChatOpen={isOpen}>{children}</StyledDocsContainer>\n );\n}\n\nexport {\n DocsWrapper,\n DocsSidebar,\n DocsContainer,\n SectionBarContext,\n SectionBarProvider,\n};\n";
|
|
@@ -11,6 +11,9 @@ import {
|
|
|
11
11
|
import Link from "next/link";
|
|
12
12
|
import { mq, Theme } from "@/app/theme";
|
|
13
13
|
import {
|
|
14
|
+
focusModeColumn,
|
|
15
|
+
focusModeHide,
|
|
16
|
+
sidePanelOffset,
|
|
14
17
|
styledAnchor,
|
|
15
18
|
styledTable,
|
|
16
19
|
stylesLists,
|
|
@@ -63,6 +66,9 @@ const StyledDocsContainer = styled.div<{ theme: Theme; $isChatOpen?: boolean }>\
|
|
|
63
66
|
\`}
|
|
64
67
|
}
|
|
65
68
|
|
|
69
|
+
\${sidePanelOffset};
|
|
70
|
+
\${({ $isChatOpen }) => !$isChatOpen && focusModeColumn};
|
|
71
|
+
|
|
66
72
|
& p {
|
|
67
73
|
color: \${({ theme }) => theme.colors.grayDark};
|
|
68
74
|
hyphens: auto;
|
|
@@ -167,6 +173,8 @@ export const StyledSidebar = styled.nav<Props>\`
|
|
|
167
173
|
opacity: 1;
|
|
168
174
|
pointer-events: all;
|
|
169
175
|
\`}
|
|
176
|
+
|
|
177
|
+
\${focusModeHide("left")};
|
|
170
178
|
\`;
|
|
171
179
|
|
|
172
180
|
export const StyledSidebarFooter = styled.div\`
|
|
@@ -212,6 +220,8 @@ export const StyledIndexSidebar = styled.ul<{ theme: Theme }>\`
|
|
|
212
220
|
& li {
|
|
213
221
|
padding: 5px 0;
|
|
214
222
|
}
|
|
223
|
+
|
|
224
|
+
\${focusModeHide("right")};
|
|
215
225
|
\`;
|
|
216
226
|
|
|
217
227
|
export const StyledIndexSidebarLabel = styled.span<{ theme: Theme }>\`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const docsNavigationTemplate = "\"use client\";\nimport { useContext } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport Link from \"next/link\";\nimport styled, { css } from \"styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {
|
|
1
|
+
export declare const docsNavigationTemplate = "\"use client\";\nimport { useContext } from \"react\";\nimport { usePathname } from \"next/navigation\";\nimport Link from \"next/link\";\nimport styled, { css } from \"styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { mq, Theme } from \"@/app/theme\";\nimport {\n focusModeColumn,\n interactiveStyles,\n sidePanelOffset,\n} from \"@/components/layout/SharedStyled\";\nimport { ChatContext } from \"@/components/Chat\";\n\nconst StyledNavigationWrapper = styled.div<{\n $isChatOpen?: boolean;\n}>`\n transition: all 0.3s ease;\n padding: 0 20px 100px 20px;\n ${mq(\"lg\")} {\n padding: 0 300px 80px 300px;\n ${({ $isChatOpen }) =>\n $isChatOpen &&\n css`\n padding: 0 440px 80px 300px;\n `}\n }\n\n ${sidePanelOffset};\n ${({ $isChatOpen }) => !$isChatOpen && focusModeColumn};\n`;\n\nconst StyledNavigationInner = styled.div`\n display: flex;\n justify-content: space-between;\n align-items: center;\n gap: 20px;\n max-width: 640px;\n margin: auto;\n`;\n\nconst StyledNavButton = styled(Link)<{ theme: Theme }>`\n ${interactiveStyles};\n display: flex;\n flex-direction: column;\n text-decoration: none;\n padding: 20px;\n flex: 50%;\n max-width: 50%;\n border-radius: ${({ theme }) => theme.spacing.radius.lg};\n border: solid 1px ${({ theme }) => theme.colors.grayLight};\n color: ${({ theme }) => theme.colors.dark};\n\n &:hover {\n border-color: ${({ theme }) => theme.colors.primary};\n }\n\n &[data-direction=\"prev\"] {\n align-items: flex-start;\n }\n\n &[data-direction=\"next\"] {\n align-items: flex-end;\n margin-left: auto;\n text-align: right;\n }\n`;\n\nconst StyledNavLabel = styled.span<{ theme: Theme }>`\n color: ${({ theme }) => theme.colors.grayDark};\n display: flex;\n flex-direction: row;\n gap: 4px;\n\n & svg {\n margin: auto 0;\n }\n`;\n\nconst StyledNavTitle = styled.span<{ theme: Theme }>`\n color: ${({ theme }) => theme.colors.dark};\n font-weight: 600;\n margin: 0 0 4px 0;\n white-space: nowrap;\n text-overflow: ellipsis;\n overflow: hidden;\n max-width: 100%;\n`;\n\nconst StyledSpacer = styled.div`\n flex: 1;\n`;\n\ninterface Page {\n // Optional: nested group nodes may act as headers without their own page.\n // collectPages() only pushes nodes that actually have a slug.\n slug?: string;\n title: string;\n category?: string;\n links?: Page[];\n items?: Page[];\n [key: string]: unknown;\n}\n\ninterface NavigationItem {\n category?: string;\n slug?: string;\n title?: string;\n links?: Page[];\n items?: Page[];\n [key: string]: unknown;\n}\n\ninterface DocsNavigationProps {\n result: NavigationItem[];\n}\n\nfunction DocsNavigation({ result }: DocsNavigationProps) {\n const { isOpen } = useContext(ChatContext);\n const pathname = usePathname();\n // Walk categories and any nested link groups depth-first so prev/next spans\n // every real page (a node with a slug), in reading order.\n const collectPages = (nodes: unknown): Page[] => {\n if (!Array.isArray(nodes)) return [];\n const pages: Page[] = [];\n for (const node of nodes as Page[]) {\n if (node && node.slug !== undefined) {\n pages.push(node);\n }\n const children = node && ((node.links ?? node.items) as unknown);\n if (Array.isArray(children)) {\n pages.push(...collectPages(children));\n }\n }\n return pages;\n };\n const allPages: Page[] = result.flatMap((item) =>\n collectPages(\n item.links ??\n item.items ??\n (item.slug !== undefined ? [item as Page] : []),\n ),\n );\n const currentSlug = pathname.replace(/^\\//, \"\").replace(/\\/$/, \"\");\n const currentIndex = allPages.findIndex((page) => page.slug === currentSlug);\n const prevPage = currentIndex > 0 ? allPages[currentIndex - 1] : null;\n const nextPage =\n currentIndex < allPages.length - 1 ? allPages[currentIndex + 1] : null;\n if (currentIndex === -1 || allPages.length === 0) {\n return null;\n }\n if (!prevPage && !nextPage) {\n return null;\n }\n return (\n <StyledNavigationWrapper $isChatOpen={isOpen}>\n <StyledNavigationInner>\n {prevPage ? (\n <StyledNavButton href={`/${prevPage.slug}`} data-direction=\"prev\">\n <StyledNavTitle>{prevPage.title}</StyledNavTitle>\n <StyledNavLabel>\n <Icon name=\"arrow-left\" size={16} /> Previous\n </StyledNavLabel>\n </StyledNavButton>\n ) : (\n <StyledSpacer />\n )}\n {nextPage && (\n <StyledNavButton href={`/${nextPage.slug}`} data-direction=\"next\">\n <StyledNavTitle>{nextPage.title}</StyledNavTitle>\n <StyledNavLabel>\n Next <Icon name=\"arrow-right\" size={16} />\n </StyledNavLabel>\n </StyledNavButton>\n )}\n </StyledNavigationInner>\n </StyledNavigationWrapper>\n );\n}\n\nexport { DocsNavigation };\n";
|
|
@@ -6,7 +6,11 @@ import Link from "next/link";
|
|
|
6
6
|
import styled, { css } from "styled-components";
|
|
7
7
|
import { Icon } from "@/components/layout/Icon";
|
|
8
8
|
import { mq, Theme } from "@/app/theme";
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
focusModeColumn,
|
|
11
|
+
interactiveStyles,
|
|
12
|
+
sidePanelOffset,
|
|
13
|
+
} from "@/components/layout/SharedStyled";
|
|
10
14
|
import { ChatContext } from "@/components/Chat";
|
|
11
15
|
|
|
12
16
|
const StyledNavigationWrapper = styled.div<{
|
|
@@ -22,6 +26,9 @@ const StyledNavigationWrapper = styled.div<{
|
|
|
22
26
|
padding: 0 ${CHAT_WIDTH + 20}px 80px ${SIDEBAR_WIDTH + 20}px;
|
|
23
27
|
\`}
|
|
24
28
|
}
|
|
29
|
+
|
|
30
|
+
\${sidePanelOffset};
|
|
31
|
+
\${({ $isChatOpen }) => !$isChatOpen && focusModeColumn};
|
|
25
32
|
\`;
|
|
26
33
|
|
|
27
34
|
const StyledNavigationInner = styled.div\`
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const focusModeToggleTemplate = "\"use client\";\nimport { useEffect, useRef, useState } from \"react\";\nimport styled from \"styled-components\";\nimport { resetButton } from \"cherry-styled-components\";\nimport { Icon } from \"@/components/layout/Icon\";\nimport { mq, Theme } from \"@/app/theme\";\nimport { interactiveStyles } from \"@/components/layout/SharedStyled\";\n\n// Desktop-only affordance that collapses both rails for distraction-free\n// reading. The button is fixed rather than living in the sidebar footer next\n// to the ThemeToggle: the footer slides away with the sidebar, and the way\n// back out of focus mode has to stay on screen.\nconst StyledFocusToggle = styled.button<{ theme: Theme }>`\n display: none;\n\n ${mq(\"lg\")} {\n ${resetButton};\n ${interactiveStyles};\n display: flex;\n align-items: center;\n justify-content: center;\n position: fixed;\n /* Above the sidebar (99) so it stays clickable once the rails are out,\n below the chat panel (1000). */\n z-index: 100;\n /* Sidebar footer row, flush with the footer's left padding (the\n ThemeToggle holds the right end of the same row). */\n left: 20px;\n bottom: 16px;\n width: 30px;\n height: 30px;\n border-radius: 50%;\n background: ${({ theme }) => theme.colors.light};\n border-color: ${({ theme }) => theme.colors.grayLight};\n\n & svg {\n width: 16px;\n height: 16px;\n }\n\n & svg[stroke] {\n stroke: ${({ theme }) => theme.colors.primary};\n }\n\n &:hover svg[stroke] {\n stroke: ${({ theme }) => theme.colors.accent};\n }\n }\n`;\n\nfunction FocusModeToggle() {\n const [isFocusMode, setIsFocusMode] = useState(false);\n const buttonRef = useRef<HTMLButtonElement>(null);\n\n // Cmd/Ctrl+B, the editor convention for collapsing the side columns. Sits\n // alongside the app's other chords (Cmd+K search, Cmd+I chat,\n // Cmd+Shift+L theme) and stays out of the way while the reader is typing.\n useEffect(() => {\n function handleKeyDown(e: KeyboardEvent) {\n if (!(e.metaKey || e.ctrlKey) || e.shiftKey || e.altKey) return;\n if (e.key.toLowerCase() !== \"b\") return;\n const target = e.target as HTMLElement | null;\n if (target?.closest(\"input, textarea, [contenteditable='true']\")) return;\n // The button is display:none below \"lg\" and focus mode is a desktop\n // layout, so the shortcut is live exactly when the button is.\n const button = buttonRef.current;\n if (!button || getComputedStyle(button).display === \"none\") return;\n e.preventDefault();\n setIsFocusMode((value) => !value);\n }\n document.addEventListener(\"keydown\", handleKeyDown);\n return () => document.removeEventListener(\"keydown\", handleKeyDown);\n }, []);\n\n // The nav sidebar, the right rail and the content columns sit in separate\n // subtrees, so the state rides on the root element and each of them reacts\n // in CSS (see focusModeHide / focusModeColumn in SharedStyled).\n useEffect(() => {\n const root = document.documentElement;\n if (isFocusMode) {\n root.setAttribute(\"data-focus-mode\", \"\");\n } else {\n root.removeAttribute(\"data-focus-mode\");\n }\n return () => root.removeAttribute(\"data-focus-mode\");\n }, [isFocusMode]);\n\n return (\n <StyledFocusToggle\n ref={buttonRef}\n type=\"button\"\n onClick={() => setIsFocusMode((value) => !value)}\n aria-pressed={isFocusMode}\n aria-label={isFocusMode ? \"Exit focus mode\" : \"Enter focus mode\"}\n title={isFocusMode ? \"Exit focus mode (\u2318B)\" : \"Focus mode (\u2318B)\"}\n >\n <Icon name={isFocusMode ? \"minimize\" : \"maximize\"} size={16} />\n </StyledFocusToggle>\n );\n}\n\nexport { FocusModeToggle };\n";
|