@karimsa/mdxserve 0.0.0-stage → 0.2.0
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/LICENSE +21 -0
- package/README.md +233 -2
- package/client/App.tsx +7 -0
- package/client/CodeBlock.tsx +395 -0
- package/client/CrossFade.tsx +72 -0
- package/client/DocContext.ts +14 -0
- package/client/DocView.tsx +107 -0
- package/client/ErrorBox.tsx +23 -0
- package/client/Heading.tsx +31 -0
- package/client/HomeEmptyState.tsx +101 -0
- package/client/HomeView.tsx +78 -0
- package/client/ListingView.tsx +663 -0
- package/client/MdSection.tsx +234 -0
- package/client/MdSectionEditor.tsx +233 -0
- package/client/Mermaid.tsx +435 -0
- package/client/RenderErrorBoundary.tsx +40 -0
- package/client/Table.tsx +14 -0
- package/client/TaskCheckbox.tsx +38 -0
- package/client/api.ts +138 -0
- package/client/app.css +372 -0
- package/client/builtins/Badge.tsx +109 -0
- package/client/builtins/Button.tsx +111 -0
- package/client/builtins/Callout.tsx +97 -0
- package/client/builtins/Card.tsx +111 -0
- package/client/builtins/Chart.tsx +875 -0
- package/client/builtins/Diff.tsx +722 -0
- package/client/builtins/Dropdown.tsx +417 -0
- package/client/builtins/FileTree.tsx +87 -0
- package/client/builtins/Kbd.tsx +18 -0
- package/client/builtins/Screenshot.tsx +209 -0
- package/client/builtins/Sparkline.tsx +63 -0
- package/client/builtins/Tabs.tsx +169 -0
- package/client/builtins/Tooltip.tsx +52 -0
- package/client/builtins/chart-data.ts +133 -0
- package/client/builtins/index.ts +167 -0
- package/client/design/base/editor.css +151 -0
- package/client/design/base/prose.css +143 -0
- package/client/design/base/reset.css +79 -0
- package/client/design/tokens/colors.css +188 -0
- package/client/design/tokens/elevation.css +42 -0
- package/client/design/tokens/fonts.css +6 -0
- package/client/design/tokens/motion.css +76 -0
- package/client/design/tokens/spacing.css +34 -0
- package/client/design/tokens/typography.css +56 -0
- package/client/doc-module-cache.ts +17 -0
- package/client/editor-link.ts +27 -0
- package/client/entry.tsx +51 -0
- package/client/export-doc.ts +80 -0
- package/client/export-save.ts +96 -0
- package/client/favicon.svg +1 -0
- package/client/file-system-access.d.ts +29 -0
- package/client/format.ts +17 -0
- package/client/hooks.ts +34 -0
- package/client/lucide-icons.d.ts +9 -0
- package/client/mdx-components-base.ts +32 -0
- package/client/mdx-components.ts +18 -0
- package/client/mermaid-chart.ts +109 -0
- package/client/mermaid-direction.ts +73 -0
- package/client/motion.ts +104 -0
- package/client/platform.ts +16 -0
- package/client/route-path.ts +15 -0
- package/client/router.ts +452 -0
- package/client/shell/AppShell.tsx +401 -0
- package/client/shell/Footer.tsx +33 -0
- package/client/shell/NotFoundView.tsx +22 -0
- package/client/shell/Sidebar.tsx +169 -0
- package/client/shell/StandaloneShell.tsx +65 -0
- package/client/shell/TocRail.tsx +53 -0
- package/client/shell/TopBar.tsx +117 -0
- package/client/shell/use-doc-width.ts +61 -0
- package/client/shell/useToc.ts +77 -0
- package/client/ssr-entry.tsx +22 -0
- package/client/standalone-entry.tsx +51 -0
- package/client/state.ts +90 -0
- package/client/theme.ts +65 -0
- package/client/ui/Breadcrumb.tsx +49 -0
- package/client/ui/ConfirmDeleteDialog.tsx +113 -0
- package/client/ui/ExpandModal.tsx +342 -0
- package/client/ui/Icon.tsx +114 -0
- package/client/ui/IconButton.tsx +63 -0
- package/client/ui/Kbd.tsx +17 -0
- package/client/ui/PageNav.tsx +77 -0
- package/client/ui/ResizeHandle.tsx +201 -0
- package/client/ui/SearchDialog.tsx +187 -0
- package/client/ui/Tag.tsx +44 -0
- package/client/ui/Toast.tsx +189 -0
- package/client/ui/TocList.tsx +71 -0
- package/client/ui/icon-set.ts +102 -0
- package/client/ui/toast-count.ts +28 -0
- package/dist/cli.js +5091 -0
- package/dist/registry.json +703 -0
- package/dist/render-worker.js +145 -0
- package/package.json +113 -5
- package/skills/mdxserve/SKILL.md +178 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { motion } from "framer-motion";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { TRANSITIONS } from "../motion";
|
|
5
|
+
import { Icon } from "../ui/Icon";
|
|
6
|
+
|
|
7
|
+
export const cardProps = z.object({
|
|
8
|
+
title: z.string().optional().describe("Card heading."),
|
|
9
|
+
description: z.string().optional().describe("One-sentence body text below the title."),
|
|
10
|
+
icon: z.string().optional().describe("Lucide icon name shown above the title."),
|
|
11
|
+
meta: z.string().optional().describe('Small uppercase mono line at the bottom, e.g. "3 pages".'),
|
|
12
|
+
href: z.string().optional().describe("Renders the card as a link and enables the hover lift."),
|
|
13
|
+
interactive: z.boolean().default(false).describe("Enables the hover lift without a link."),
|
|
14
|
+
children: z
|
|
15
|
+
.custom<ReactNode>()
|
|
16
|
+
.optional()
|
|
17
|
+
.describe("Extra content rendered below the description/meta."),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type CardProps = z.infer<typeof cardProps>;
|
|
21
|
+
|
|
22
|
+
export default function Card({
|
|
23
|
+
title,
|
|
24
|
+
description,
|
|
25
|
+
icon,
|
|
26
|
+
meta,
|
|
27
|
+
href,
|
|
28
|
+
interactive = false,
|
|
29
|
+
children,
|
|
30
|
+
}: CardProps) {
|
|
31
|
+
const clickable = interactive || Boolean(href);
|
|
32
|
+
const className = [
|
|
33
|
+
"not-prose group block rounded-lg border p-5 text-text-body no-underline",
|
|
34
|
+
"bg-surface-card transition-shadow duration-150",
|
|
35
|
+
clickable
|
|
36
|
+
? "cursor-pointer border-border-default hover:border-border-accent hover:shadow-sm"
|
|
37
|
+
: "border-border-default",
|
|
38
|
+
"shadow-xs",
|
|
39
|
+
].join(" ");
|
|
40
|
+
|
|
41
|
+
const inner = (
|
|
42
|
+
<>
|
|
43
|
+
{icon ? <Icon name={icon} size="lg" className="mb-3 text-text-accent" /> : null}
|
|
44
|
+
{title ? (
|
|
45
|
+
<div className="flex items-center gap-2 font-sans font-semibold leading-[1.4] text-[length:var(--size-md)] text-text-heading">
|
|
46
|
+
<span>{title}</span>
|
|
47
|
+
{clickable ? (
|
|
48
|
+
<span className="inline-flex text-text-subtle opacity-60 transition-[transform,opacity] duration-150 ease-standard group-hover:translate-x-0.5 group-hover:opacity-100">
|
|
49
|
+
<Icon name="arrow-right" size="sm" />
|
|
50
|
+
</span>
|
|
51
|
+
) : null}
|
|
52
|
+
</div>
|
|
53
|
+
) : null}
|
|
54
|
+
{description ? (
|
|
55
|
+
<p className="mt-2 font-sans font-medium text-[length:var(--size-sm)] leading-[1.55] text-text-muted">
|
|
56
|
+
{description}
|
|
57
|
+
</p>
|
|
58
|
+
) : null}
|
|
59
|
+
{meta ? (
|
|
60
|
+
<div className="mt-3 font-mono font-semibold leading-[1.2] text-[length:var(--size-2xs)] uppercase tracking-[var(--tracking-wide)] text-text-subtle">
|
|
61
|
+
{meta}
|
|
62
|
+
</div>
|
|
63
|
+
) : null}
|
|
64
|
+
{children}
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (href) {
|
|
69
|
+
return (
|
|
70
|
+
<motion.a
|
|
71
|
+
href={href}
|
|
72
|
+
whileHover={{ y: -2 }}
|
|
73
|
+
whileTap={{ y: 0, scale: 0.995 }}
|
|
74
|
+
transition={TRANSITIONS.snap}
|
|
75
|
+
className={className}
|
|
76
|
+
>
|
|
77
|
+
{inner}
|
|
78
|
+
</motion.a>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<motion.div
|
|
84
|
+
whileHover={clickable ? { y: -2 } : undefined}
|
|
85
|
+
whileTap={clickable ? { y: 0, scale: 0.995 } : undefined}
|
|
86
|
+
transition={TRANSITIONS.snap}
|
|
87
|
+
className={className}
|
|
88
|
+
>
|
|
89
|
+
{inner}
|
|
90
|
+
</motion.div>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const cardGridProps = z.object({
|
|
95
|
+
columns: z
|
|
96
|
+
.enum(["2", "3"])
|
|
97
|
+
.default("2")
|
|
98
|
+
.describe("Maximum columns at the widest breakpoint; fewer on narrower screens."),
|
|
99
|
+
children: z.custom<ReactNode>().describe("One or more `<Card>` elements."),
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
export type CardGridProps = z.infer<typeof cardGridProps>;
|
|
103
|
+
|
|
104
|
+
const GRID_COLS: Record<NonNullable<CardGridProps["columns"]>, string> = {
|
|
105
|
+
"2": "sm:grid-cols-2",
|
|
106
|
+
"3": "sm:grid-cols-2 lg:grid-cols-3",
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export function CardGrid({ columns = "2", children }: CardGridProps) {
|
|
110
|
+
return <div className={`not-prose grid grid-cols-1 gap-4 ${GRID_COLS[columns]}`}>{children}</div>;
|
|
111
|
+
}
|