forked from CopilotKit/CopilotKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmdx-components.tsx
More file actions
89 lines (84 loc) · 2.92 KB
/
Copy pathmdx-components.tsx
File metadata and controls
89 lines (84 loc) · 2.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import type React from "react";
import {
Card as FumadocsCard,
Cards as FumadocsCards,
} from "fumadocs-ui/components/card";
// Re-export fumadocs's default `<Callout>` so historical imports from
// `@/components/mdx-components` keep working. Fumadocs supports the
// types `info | warn | warning | error | success | idea`, plus the
// alias `tip` (resolves to info). Other custom types fall back to the
// default tone.
export { Callout } from "fumadocs-ui/components/callout";
export function Cards({
className,
...props
}: React.ComponentProps<typeof FumadocsCards>) {
// `not-prose` opts the wrapped Cards out of the .reference-content
// prose-link styling (which forces underline + accent color on every
// <a>). The Card's own className already controls link appearance.
return (
<FumadocsCards
{...props}
className={["not-prose my-6 grid-cols-1 gap-4 sm:grid-cols-2", className]
.filter(Boolean)
.join(" ")}
/>
);
}
export function Card({
href,
className,
style,
...props
}: React.ComponentProps<typeof FumadocsCard>) {
// Match the docs-landing pointer-card style:
// - bordered surface, accent border on hover, subtle shadow on hover
// - title flips to accent color on hover via `group-hover` so the link
// feels active without using a default underline
// - `not-prose` is the load-bearing class: the article body uses
// `.reference-content` which forces `text-decoration: underline;
// color: var(--accent)` on every <a>; that rule wins over the
// Tailwind `no-underline` class on specificity. `not-prose`
// triggers the global escape-hatch rule that drops both.
const resolvedHref = href?.replace(/^\/reference\/v2\//, "/reference/");
const mergedClassName = [
"shell-docs-radius-surface border-[var(--border)] bg-[var(--bg-surface)] text-[var(--text)] shadow-[var(--shadow-control)]",
href
? "not-prose hover:border-[var(--accent)] hover:bg-[var(--bg-elevated)]"
: null,
className,
]
.filter(Boolean)
.join(" ");
return (
<FumadocsCard
{...props}
href={resolvedHref}
className={mergedClassName}
style={
href ? { textDecoration: "none", color: "inherit", ...style } : style
}
/>
);
}
export function Accordions({ children }: { children: React.ReactNode }) {
return <div className="my-4 space-y-2">{children}</div>;
}
export function Accordion({
title,
children,
}: {
title: string;
children: React.ReactNode;
}) {
return (
<details className="shell-docs-radius-surface group border border-[var(--border)] bg-[var(--bg-surface)] shadow-[var(--shadow-control)]">
<summary className="cursor-pointer select-none px-4 py-3 text-sm font-semibold text-[var(--text)] transition-colors hover:bg-[var(--bg-elevated)]">
{title}
</summary>
<div className="px-4 pb-4 text-sm text-[var(--text-secondary)]">
{children}
</div>
</details>
);
}