@farming-labs/theme 0.0.47 → 0.0.50
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/colorful/index.d.mts +4 -0
- package/dist/colorful/index.mjs +4 -0
- package/dist/darkbold/index.d.mts +4 -0
- package/dist/darkbold/index.mjs +4 -0
- package/dist/darksharp/index.d.mts +4 -0
- package/dist/darksharp/index.mjs +4 -0
- package/dist/default/index.d.mts +4 -0
- package/dist/default/index.mjs +4 -0
- package/dist/greentree/index.d.mts +4 -0
- package/dist/greentree/index.mjs +4 -0
- package/dist/hover-link.d.mts +36 -0
- package/dist/hover-link.mjs +210 -0
- package/dist/index.d.mts +2 -1
- package/dist/index.mjs +2 -1
- package/dist/mdx.d.mts +6 -2
- package/dist/mdx.mjs +56 -3
- package/dist/pixel-border/index.d.mts +6 -1
- package/dist/pixel-border/index.mjs +4 -1
- package/dist/shiny/index.d.mts +4 -0
- package/dist/shiny/index.mjs +4 -0
- package/package.json +2 -2
package/dist/colorful/index.mjs
CHANGED
package/dist/darkbold/index.mjs
CHANGED
package/dist/darksharp/index.mjs
CHANGED
package/dist/default/index.d.mts
CHANGED
package/dist/default/index.mjs
CHANGED
package/dist/greentree/index.mjs
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
3
|
+
|
|
4
|
+
//#region src/hover-link.d.ts
|
|
5
|
+
interface HoverLinkProps {
|
|
6
|
+
href: string;
|
|
7
|
+
title: string;
|
|
8
|
+
description: string;
|
|
9
|
+
children: ReactNode;
|
|
10
|
+
linkLabel?: string;
|
|
11
|
+
previewLabel?: string;
|
|
12
|
+
external?: boolean;
|
|
13
|
+
prefetch?: boolean;
|
|
14
|
+
showIndicator?: boolean;
|
|
15
|
+
align?: "start" | "center" | "end";
|
|
16
|
+
side?: "top" | "right" | "bottom" | "left";
|
|
17
|
+
sideOffset?: number;
|
|
18
|
+
closeDelay?: number;
|
|
19
|
+
}
|
|
20
|
+
declare function HoverLink({
|
|
21
|
+
href,
|
|
22
|
+
title,
|
|
23
|
+
description,
|
|
24
|
+
children,
|
|
25
|
+
linkLabel,
|
|
26
|
+
previewLabel,
|
|
27
|
+
external,
|
|
28
|
+
prefetch,
|
|
29
|
+
showIndicator,
|
|
30
|
+
align,
|
|
31
|
+
side,
|
|
32
|
+
sideOffset,
|
|
33
|
+
closeDelay
|
|
34
|
+
}: HoverLinkProps): react_jsx_runtime0.JSX.Element;
|
|
35
|
+
//#endregion
|
|
36
|
+
export { HoverLink, HoverLinkProps };
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import Link from "fumadocs-core/link";
|
|
6
|
+
import { Popover, PopoverContent, PopoverTrigger } from "fumadocs-ui/components/ui/popover";
|
|
7
|
+
|
|
8
|
+
//#region src/hover-link.tsx
|
|
9
|
+
function HoverLink({ href, title, description, children, linkLabel = "Open page", previewLabel, external, prefetch, showIndicator = false, align = "center", side = "bottom", sideOffset = 12, closeDelay = 90 }) {
|
|
10
|
+
const [open, setOpen] = useState(false);
|
|
11
|
+
const closeTimerRef = useRef(null);
|
|
12
|
+
const triggerRef = useRef(null);
|
|
13
|
+
const contentRef = useRef(null);
|
|
14
|
+
const underlineColor = open ? "color-mix(in srgb, var(--color-fd-foreground, currentColor) 68%, transparent)" : "color-mix(in srgb, var(--color-fd-foreground, currentColor) 46%, transparent)";
|
|
15
|
+
function clearCloseTimer() {
|
|
16
|
+
if (closeTimerRef.current !== null) {
|
|
17
|
+
window.clearTimeout(closeTimerRef.current);
|
|
18
|
+
closeTimerRef.current = null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function openPopover() {
|
|
22
|
+
clearCloseTimer();
|
|
23
|
+
setOpen(true);
|
|
24
|
+
}
|
|
25
|
+
function closePopover() {
|
|
26
|
+
clearCloseTimer();
|
|
27
|
+
closeTimerRef.current = window.setTimeout(() => setOpen(false), closeDelay);
|
|
28
|
+
}
|
|
29
|
+
function isWithinHoverArea(target) {
|
|
30
|
+
if (!(target instanceof Node)) return false;
|
|
31
|
+
return triggerRef.current !== null && triggerRef.current.contains(target) || contentRef.current !== null && contentRef.current.contains(target);
|
|
32
|
+
}
|
|
33
|
+
function shouldOpenFromFocus(element) {
|
|
34
|
+
return typeof element.matches === "function" && element.matches(":focus-visible");
|
|
35
|
+
}
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
return () => {
|
|
38
|
+
if (closeTimerRef.current !== null) window.clearTimeout(closeTimerRef.current);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return /* @__PURE__ */ jsxs(Popover, {
|
|
42
|
+
open,
|
|
43
|
+
onOpenChange: (nextOpen) => {
|
|
44
|
+
clearCloseTimer();
|
|
45
|
+
setOpen(nextOpen);
|
|
46
|
+
},
|
|
47
|
+
children: [/* @__PURE__ */ jsx(PopoverTrigger, {
|
|
48
|
+
asChild: true,
|
|
49
|
+
children: /* @__PURE__ */ jsxs("button", {
|
|
50
|
+
ref: triggerRef,
|
|
51
|
+
type: "button",
|
|
52
|
+
onPointerEnter: openPopover,
|
|
53
|
+
onPointerLeave: (event) => {
|
|
54
|
+
if (isWithinHoverArea(event.relatedTarget)) return;
|
|
55
|
+
closePopover();
|
|
56
|
+
},
|
|
57
|
+
onFocus: (event) => {
|
|
58
|
+
if (!shouldOpenFromFocus(event.currentTarget)) return;
|
|
59
|
+
openPopover();
|
|
60
|
+
},
|
|
61
|
+
onBlur: (event) => {
|
|
62
|
+
if (isWithinHoverArea(event.relatedTarget)) return;
|
|
63
|
+
closePopover();
|
|
64
|
+
},
|
|
65
|
+
onClick: openPopover,
|
|
66
|
+
style: {
|
|
67
|
+
display: "inline",
|
|
68
|
+
border: "none",
|
|
69
|
+
background: "transparent",
|
|
70
|
+
padding: 0,
|
|
71
|
+
margin: 0,
|
|
72
|
+
color: "var(--color-fd-foreground, currentColor)",
|
|
73
|
+
cursor: "pointer",
|
|
74
|
+
textDecoration: "underline",
|
|
75
|
+
textDecorationStyle: "dashed",
|
|
76
|
+
textDecorationThickness: "0.08em",
|
|
77
|
+
textUnderlineOffset: "0.22em",
|
|
78
|
+
textDecorationColor: underlineColor,
|
|
79
|
+
font: "inherit",
|
|
80
|
+
lineHeight: "inherit",
|
|
81
|
+
verticalAlign: "baseline",
|
|
82
|
+
appearance: "none",
|
|
83
|
+
transition: "text-decoration-color 180ms ease"
|
|
84
|
+
},
|
|
85
|
+
children: [/* @__PURE__ */ jsx("span", { children }), showIndicator ? /* @__PURE__ */ jsx("span", {
|
|
86
|
+
"aria-hidden": "true",
|
|
87
|
+
style: {
|
|
88
|
+
marginInlineStart: "0.3em",
|
|
89
|
+
fontSize: "0.75em",
|
|
90
|
+
opacity: .8
|
|
91
|
+
},
|
|
92
|
+
children: "+"
|
|
93
|
+
}) : null]
|
|
94
|
+
})
|
|
95
|
+
}), /* @__PURE__ */ jsx(PopoverContent, {
|
|
96
|
+
ref: contentRef,
|
|
97
|
+
align,
|
|
98
|
+
side,
|
|
99
|
+
sideOffset,
|
|
100
|
+
onPointerEnter: openPopover,
|
|
101
|
+
onPointerLeave: (event) => {
|
|
102
|
+
if (isWithinHoverArea(event.relatedTarget)) return;
|
|
103
|
+
closePopover();
|
|
104
|
+
},
|
|
105
|
+
onFocusCapture: openPopover,
|
|
106
|
+
onBlurCapture: (event) => {
|
|
107
|
+
if (isWithinHoverArea(event.relatedTarget)) return;
|
|
108
|
+
closePopover();
|
|
109
|
+
},
|
|
110
|
+
onInteractOutside: () => {
|
|
111
|
+
clearCloseTimer();
|
|
112
|
+
setOpen(false);
|
|
113
|
+
},
|
|
114
|
+
onCloseAutoFocus: (event) => {
|
|
115
|
+
event.preventDefault();
|
|
116
|
+
},
|
|
117
|
+
style: {
|
|
118
|
+
width: "min(22rem, calc(100vw - 2rem))",
|
|
119
|
+
borderRadius: "calc(var(--radius, 0.75rem) + 2px)",
|
|
120
|
+
border: "1px solid color-mix(in srgb, var(--color-fd-border, #2a2a2a) 88%, transparent)",
|
|
121
|
+
background: "var(--color-fd-popover, var(--color-fd-background, #0b0b0b))",
|
|
122
|
+
color: "var(--color-fd-popover-foreground, var(--color-fd-foreground, currentColor))",
|
|
123
|
+
padding: "0.95rem 1rem",
|
|
124
|
+
boxShadow: "0 20px 45px color-mix(in srgb, var(--color-fd-background, #000) 78%, transparent)",
|
|
125
|
+
backdropFilter: "blur(14px)"
|
|
126
|
+
},
|
|
127
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
128
|
+
style: {
|
|
129
|
+
display: "flex",
|
|
130
|
+
flexDirection: "column",
|
|
131
|
+
gap: "0.75rem"
|
|
132
|
+
},
|
|
133
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
134
|
+
style: {
|
|
135
|
+
display: "flex",
|
|
136
|
+
flexDirection: "column",
|
|
137
|
+
gap: "0.35rem"
|
|
138
|
+
},
|
|
139
|
+
children: [
|
|
140
|
+
previewLabel ? /* @__PURE__ */ jsx("span", {
|
|
141
|
+
style: {
|
|
142
|
+
fontSize: "0.68rem",
|
|
143
|
+
textTransform: "uppercase",
|
|
144
|
+
letterSpacing: "0.1em",
|
|
145
|
+
fontFamily: "var(--fd-font-mono, var(--font-geist-mono, ui-monospace, monospace))",
|
|
146
|
+
color: "color-mix(in srgb, var(--color-fd-popover-foreground, currentColor) 55%, transparent)"
|
|
147
|
+
},
|
|
148
|
+
children: previewLabel
|
|
149
|
+
}) : null,
|
|
150
|
+
/* @__PURE__ */ jsx(Link, {
|
|
151
|
+
href,
|
|
152
|
+
external,
|
|
153
|
+
prefetch,
|
|
154
|
+
style: {
|
|
155
|
+
fontSize: "1rem",
|
|
156
|
+
fontWeight: 600,
|
|
157
|
+
lineHeight: 1.3,
|
|
158
|
+
color: "var(--color-fd-popover-foreground, currentColor)",
|
|
159
|
+
textDecoration: "none"
|
|
160
|
+
},
|
|
161
|
+
children: title
|
|
162
|
+
}),
|
|
163
|
+
/* @__PURE__ */ jsx("p", {
|
|
164
|
+
style: {
|
|
165
|
+
margin: 0,
|
|
166
|
+
fontSize: "0.92rem",
|
|
167
|
+
lineHeight: 1.6,
|
|
168
|
+
color: "color-mix(in srgb, var(--color-fd-popover-foreground, currentColor) 74%, transparent)"
|
|
169
|
+
},
|
|
170
|
+
children: description
|
|
171
|
+
})
|
|
172
|
+
]
|
|
173
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
174
|
+
style: {
|
|
175
|
+
display: "flex",
|
|
176
|
+
alignItems: "center",
|
|
177
|
+
justifyContent: "space-between",
|
|
178
|
+
gap: "0.75rem",
|
|
179
|
+
paddingTop: "0.25rem",
|
|
180
|
+
borderTop: "1px solid color-mix(in srgb, var(--color-fd-border, #2a2a2a) 72%, transparent)"
|
|
181
|
+
},
|
|
182
|
+
children: /* @__PURE__ */ jsxs(Link, {
|
|
183
|
+
href,
|
|
184
|
+
external,
|
|
185
|
+
prefetch,
|
|
186
|
+
style: {
|
|
187
|
+
display: "inline-flex",
|
|
188
|
+
alignItems: "center",
|
|
189
|
+
gap: "0.4rem",
|
|
190
|
+
fontSize: "0.8rem",
|
|
191
|
+
fontWeight: 600,
|
|
192
|
+
textTransform: "uppercase",
|
|
193
|
+
letterSpacing: "0.08em",
|
|
194
|
+
fontFamily: "var(--fd-font-mono, var(--font-geist-mono, ui-monospace, monospace))",
|
|
195
|
+
color: "var(--color-fd-primary, var(--color-fd-popover-foreground, currentColor))",
|
|
196
|
+
textDecoration: "none"
|
|
197
|
+
},
|
|
198
|
+
children: [linkLabel, /* @__PURE__ */ jsx("span", {
|
|
199
|
+
"aria-hidden": "true",
|
|
200
|
+
children: "→"
|
|
201
|
+
})]
|
|
202
|
+
})
|
|
203
|
+
})]
|
|
204
|
+
})
|
|
205
|
+
})]
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
//#endregion
|
|
210
|
+
export { HoverLink };
|
package/dist/index.d.mts
CHANGED
|
@@ -5,9 +5,10 @@ import { DocsPageClient } from "./docs-page-client.mjs";
|
|
|
5
5
|
import { RootProvider } from "./provider.mjs";
|
|
6
6
|
import { PageActions } from "./page-actions.mjs";
|
|
7
7
|
import { withLangInUrl } from "./i18n.mjs";
|
|
8
|
+
import { HoverLink, HoverLinkProps } from "./hover-link.mjs";
|
|
8
9
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
9
10
|
import { AIConfig, BreadcrumbConfig, CopyMarkdownConfig, DocsConfig, DocsMetadata, DocsNav, DocsTheme, FontStyle, OGConfig, OpenDocsConfig, OpenDocsProvider, PageActionsConfig, PageFrontmatter, SidebarConfig, ThemeToggleConfig, TypographyConfig, UIConfig, createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
|
|
10
11
|
import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
|
|
11
12
|
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
12
13
|
import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
|
|
13
|
-
export { type AIConfig, type BreadcrumbConfig, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, type CopyMarkdownConfig, DocsBody, DocsCommandSearch, type DocsConfig, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, type TypographyConfig, type UIConfig, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, withLangInUrl };
|
|
14
|
+
export { type AIConfig, type BreadcrumbConfig, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, type CopyMarkdownConfig, DocsBody, DocsCommandSearch, type DocsConfig, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, HoverLink, type HoverLinkProps, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, type TypographyConfig, type UIConfig, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, withLangInUrl };
|
package/dist/index.mjs
CHANGED
|
@@ -5,10 +5,11 @@ import { DocsCommandSearch } from "./docs-command-search.mjs";
|
|
|
5
5
|
import { createDocsLayout, createDocsMetadata, createPageMetadata } from "./docs-layout.mjs";
|
|
6
6
|
import { RootProvider } from "./provider.mjs";
|
|
7
7
|
import { DefaultUIDefaults, fumadocs } from "./default/index.mjs";
|
|
8
|
+
import { HoverLink } from "./hover-link.mjs";
|
|
8
9
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
9
10
|
import { createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
|
|
10
11
|
import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
|
|
11
12
|
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
12
13
|
import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
|
|
13
14
|
|
|
14
|
-
export { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, DocsBody, DocsCommandSearch, DocsLayout, DocsPage, DocsPageClient, DefaultUIDefaults as FumadocsUIDefaults, PageActions, Pre, RootProvider, Tab, Tabs, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, withLangInUrl };
|
|
15
|
+
export { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, DocsBody, DocsCommandSearch, DocsLayout, DocsPage, DocsPageClient, DefaultUIDefaults as FumadocsUIDefaults, HoverLink, PageActions, Pre, RootProvider, Tab, Tabs, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, withLangInUrl };
|
package/dist/mdx.d.mts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { HoverLink } from "./hover-link.mjs";
|
|
1
2
|
import { MDXImg } from "./mdx-img.mjs";
|
|
2
3
|
import React from "react";
|
|
3
|
-
import { CodeBlockCopyData } from "@farming-labs/docs";
|
|
4
|
+
import { CodeBlockCopyData, DocsTheme } from "@farming-labs/docs";
|
|
4
5
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
5
6
|
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
6
7
|
import * as fumadocs_ui_components_codeblock0 from "fumadocs-ui/components/codeblock";
|
|
@@ -11,6 +12,7 @@ import * as fumadocs_ui_components_callout0 from "fumadocs-ui/components/callout
|
|
|
11
12
|
//#region src/mdx.d.ts
|
|
12
13
|
declare const extendedMdxComponents: {
|
|
13
14
|
img: typeof MDXImg;
|
|
15
|
+
HoverLink: typeof HoverLink;
|
|
14
16
|
Tab: typeof Tab;
|
|
15
17
|
Tabs: typeof Tabs;
|
|
16
18
|
CodeBlockTab: typeof fumadocs_ui_components_codeblock0.CodeBlockTab;
|
|
@@ -36,7 +38,9 @@ declare const extendedMdxComponents: {
|
|
|
36
38
|
interface GetMDXComponentsOptions {
|
|
37
39
|
/** Called when the user clicks the copy button on a code block (in addition to the default copy). */
|
|
38
40
|
onCopyClick?: (data: CodeBlockCopyData) => void;
|
|
41
|
+
/** Theme config used to apply built-in MDX component defaults from `theme.ui.components`. */
|
|
42
|
+
theme?: DocsTheme;
|
|
39
43
|
}
|
|
40
44
|
declare function getMDXComponents<T extends Record<string, unknown> = Record<string, unknown>>(overrides?: T, options?: GetMDXComponentsOptions): typeof extendedMdxComponents & T;
|
|
41
45
|
//#endregion
|
|
42
|
-
export { GetMDXComponentsOptions, Tab, Tabs, defaultMdxComponents, extendedMdxComponents, getMDXComponents };
|
|
46
|
+
export { GetMDXComponentsOptions, HoverLink, Tab, Tabs, defaultMdxComponents, extendedMdxComponents, getMDXComponents };
|
package/dist/mdx.mjs
CHANGED
|
@@ -1,26 +1,79 @@
|
|
|
1
|
+
import { HoverLink } from "./hover-link.mjs";
|
|
1
2
|
import { MDXImg } from "./mdx-img.mjs";
|
|
2
3
|
import { createPreWithCopyCallback } from "./code-block-copy-wrapper.mjs";
|
|
4
|
+
import React from "react";
|
|
3
5
|
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
4
6
|
import defaultMdxComponents from "fumadocs-ui/mdx";
|
|
5
7
|
|
|
6
8
|
//#region src/mdx.ts
|
|
9
|
+
/**
|
|
10
|
+
* Re-export fumadocs-ui MDX components.
|
|
11
|
+
*
|
|
12
|
+
* Includes all default MDX components (headings, code blocks, callouts, cards)
|
|
13
|
+
* plus Tabs/Tab for tabbed content and InstallTabs for package manager tabs.
|
|
14
|
+
* Overrides `img` so that  in markdown works without width/height
|
|
15
|
+
* (uses Next Image with unoptimized + default dimensions for external URLs).
|
|
16
|
+
*
|
|
17
|
+
* When `options.onCopyClick` is provided, the default `pre` component is wrapped
|
|
18
|
+
* so that the callback is fired when the user clicks the code block copy button.
|
|
19
|
+
*
|
|
20
|
+
* Usage in mdx-components.tsx:
|
|
21
|
+
* import { getMDXComponents } from "@farming-labs/theme/mdx";
|
|
22
|
+
* return getMDXComponents(
|
|
23
|
+
* { ...docsConfig.components, ...components },
|
|
24
|
+
* { onCopyClick: docsConfig.onCopyClick, theme: docsConfig.theme }
|
|
25
|
+
* );
|
|
26
|
+
*/
|
|
7
27
|
const extendedMdxComponents = {
|
|
8
28
|
...defaultMdxComponents,
|
|
9
29
|
img: MDXImg,
|
|
30
|
+
HoverLink,
|
|
10
31
|
Tab,
|
|
11
32
|
Tabs
|
|
12
33
|
};
|
|
34
|
+
const mdxComponentDefaults = { HoverLink: {
|
|
35
|
+
linkLabel: "Open page",
|
|
36
|
+
showIndicator: false,
|
|
37
|
+
align: "center",
|
|
38
|
+
side: "bottom",
|
|
39
|
+
sideOffset: 12,
|
|
40
|
+
closeDelay: 90
|
|
41
|
+
} };
|
|
42
|
+
function applyBuiltInComponentDefaults(options) {
|
|
43
|
+
const themeComponents = options?.theme?.ui?.components;
|
|
44
|
+
if (!themeComponents) return extendedMdxComponents;
|
|
45
|
+
const entries = Object.entries(themeComponents);
|
|
46
|
+
if (entries.length === 0) return extendedMdxComponents;
|
|
47
|
+
const components = { ...extendedMdxComponents };
|
|
48
|
+
for (const [name, value] of entries) {
|
|
49
|
+
const Component = components[name];
|
|
50
|
+
if (!Component) continue;
|
|
51
|
+
const builtInDefaults = mdxComponentDefaults[name] ?? {};
|
|
52
|
+
const componentDefaults = typeof value === "function" ? value(builtInDefaults) : {
|
|
53
|
+
...builtInDefaults,
|
|
54
|
+
...value ?? {}
|
|
55
|
+
};
|
|
56
|
+
if (!componentDefaults || typeof componentDefaults !== "object") continue;
|
|
57
|
+
components[name] = function ThemedComponent(props) {
|
|
58
|
+
return React.createElement(Component, {
|
|
59
|
+
...componentDefaults,
|
|
60
|
+
...props
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return components;
|
|
65
|
+
}
|
|
13
66
|
function getMDXComponents(overrides, options) {
|
|
14
67
|
const base = {
|
|
15
|
-
...
|
|
68
|
+
...applyBuiltInComponentDefaults(options),
|
|
16
69
|
...overrides
|
|
17
70
|
};
|
|
18
71
|
if (options?.onCopyClick) {
|
|
19
|
-
const DefaultPre =
|
|
72
|
+
const DefaultPre = base.pre;
|
|
20
73
|
if (DefaultPre) base.pre = createPreWithCopyCallback(DefaultPre, options.onCopyClick);
|
|
21
74
|
}
|
|
22
75
|
return base;
|
|
23
76
|
}
|
|
24
77
|
|
|
25
78
|
//#endregion
|
|
26
|
-
export { Tab, Tabs, defaultMdxComponents, extendedMdxComponents, getMDXComponents };
|
|
79
|
+
export { HoverLink, Tab, Tabs, defaultMdxComponents, extendedMdxComponents, getMDXComponents };
|
package/dist/shiny/index.d.mts
CHANGED
package/dist/shiny/index.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.50",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -110,7 +110,7 @@
|
|
|
110
110
|
"tsdown": "^0.20.3",
|
|
111
111
|
"typescript": "^5.9.3",
|
|
112
112
|
"vitest": "^3.2.4",
|
|
113
|
-
"@farming-labs/docs": "0.0.
|
|
113
|
+
"@farming-labs/docs": "0.0.50"
|
|
114
114
|
},
|
|
115
115
|
"peerDependencies": {
|
|
116
116
|
"@farming-labs/docs": ">=0.0.1",
|