@themodcraft/addon-docs 1.1.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/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # `@themodcraft/addon-docs`
2
+
3
+ Professional docs UI components for product docs, component registries, and internal handbooks.
4
+
5
+ Install:
6
+ ```bash
7
+ npm install @themodcraft/addon-docs
8
+ ```
9
+
10
+ The first component is `DocsSidebar`, the same sidebar pattern used by the TMC Nexus docs.
11
+
12
+ ```tsx
13
+ import { DocsSidebar } from "@themodcraft/addon-docs";
14
+
15
+ <DocsSidebar
16
+ currentPath="/components/button"
17
+ groups={[
18
+ {
19
+ label: "Components",
20
+ items: [
21
+ { href: "/components/button", label: "Button" },
22
+ { href: "/components/input", label: "Input" },
23
+ ],
24
+ },
25
+ ]}
26
+ title="Acme UI"
27
+ version="v1.0.0"
28
+ />
29
+ ```
30
+
31
+ This package publishes compiled output only.
@@ -0,0 +1,2 @@
1
+ import type { DocsSidebarProps } from "./DocsSidebar.types";
2
+ export declare function DocsSidebar({ className, currentPath, footer, groups, normalizeHref, title, version, ...props }: DocsSidebarProps): import("react").JSX.Element;
@@ -0,0 +1,13 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { LicenseGate } from "@themodcraft/license-client";
4
+ import styles from "./DocsSidebar.module.css";
5
+ function defaultNormalizeHref(href) {
6
+ return href.split("#")[0] || "/";
7
+ }
8
+ export function DocsSidebar({ className, currentPath, footer, groups, normalizeHref = defaultNormalizeHref, title, version, ...props }) {
9
+ return (_jsx(LicenseGate, { required: "addon-docs", children: _jsx("aside", { className: [styles.sidebar, className].filter(Boolean).join(" "), ...props, children: _jsxs("div", { className: styles.inner, children: [title || version ? (_jsxs("div", { className: styles.brand, children: [title ? _jsx("p", { className: styles.title, children: title }) : null, version ? _jsx("p", { className: styles.version, children: version }) : null] })) : null, _jsx("nav", { className: styles.nav, children: groups.map((group, groupIndex) => (_jsxs("section", { className: styles.group, children: [_jsx("p", { className: styles.groupLabel, children: group.label }), _jsx("div", { className: styles.groupItems, children: group.items.map((item) => {
10
+ const active = Boolean(currentPath && !item.href.includes("#") && normalizeHref(item.href) === currentPath);
11
+ return (_jsxs("a", { "aria-current": active ? "page" : undefined, className: [styles.link, active ? styles.linkActive : ""].filter(Boolean).join(" "), href: item.href, children: [_jsx("span", { className: styles.label, children: item.label }), item.badge ? _jsx("span", { className: styles.badge, children: item.badge }) : null] }, item.href));
12
+ }) })] }, `${String(group.label)}-${groupIndex}`))) }), footer ? _jsx("div", { className: styles.footer, children: footer }) : null] }) }) }));
13
+ }
@@ -0,0 +1,113 @@
1
+ .sidebar {
2
+ --tmc-docs-sidebar-background: var(--tmc-color-surface-raised, #ffffff);
3
+ --tmc-docs-sidebar-border: var(--tmc-color-border, #d7dde5);
4
+ --tmc-docs-sidebar-card-background: var(--tmc-color-surface-raised, #ffffff);
5
+ --tmc-docs-sidebar-heading: var(--tmc-color-text, #151821);
6
+ --tmc-docs-sidebar-muted: var(--tmc-color-text-muted, #5f6b7a);
7
+ --tmc-docs-sidebar-link: var(--tmc-color-text-muted, #4a5565);
8
+ --tmc-docs-sidebar-link-active-background: var(--tmc-color-text, #151821);
9
+ --tmc-docs-sidebar-link-active-text: var(--tmc-color-surface, #ffffff);
10
+ --tmc-docs-sidebar-link-hover: var(--tmc-color-hover, color-mix(in srgb, var(--tmc-color-accent, #2454d6) 10%, transparent));
11
+ color: var(--tmc-docs-sidebar-heading);
12
+ display: block;
13
+ width: 100%;
14
+ }
15
+
16
+ .inner {
17
+ max-height: calc(100vh - 96px);
18
+ overflow-y: auto;
19
+ padding-right: 1rem;
20
+ position: sticky;
21
+ top: 82px;
22
+ }
23
+
24
+ .brand {
25
+ background: var(--tmc-docs-sidebar-card-background);
26
+ border: 1px solid var(--tmc-docs-sidebar-border);
27
+ border-radius: 8px;
28
+ box-shadow: 0 10px 26px rgb(20 24 33 / 0.06);
29
+ margin-bottom: 1.25rem;
30
+ padding: 0.75rem;
31
+ }
32
+
33
+ .title {
34
+ color: var(--tmc-docs-sidebar-heading);
35
+ font-size: 0.92rem;
36
+ font-weight: 750;
37
+ margin: 0;
38
+ }
39
+
40
+ .version {
41
+ color: var(--tmc-docs-sidebar-muted);
42
+ font-size: 0.78rem;
43
+ margin: 0.25rem 0 0;
44
+ }
45
+
46
+ .nav {
47
+ display: grid;
48
+ font-size: 0.9rem;
49
+ gap: 1.5rem;
50
+ }
51
+
52
+ .group {
53
+ margin: 0;
54
+ }
55
+
56
+ .groupLabel {
57
+ color: var(--tmc-docs-sidebar-muted);
58
+ font-size: 0.72rem;
59
+ font-weight: 800;
60
+ letter-spacing: 0.14em;
61
+ margin: 0 0 0.5rem;
62
+ padding: 0 0.5rem;
63
+ text-transform: uppercase;
64
+ }
65
+
66
+ .groupItems {
67
+ display: grid;
68
+ gap: 0.25rem;
69
+ }
70
+
71
+ .link {
72
+ align-items: center;
73
+ border-radius: 7px;
74
+ color: var(--tmc-docs-sidebar-link);
75
+ display: flex;
76
+ gap: 0.5rem;
77
+ justify-content: space-between;
78
+ min-height: 2rem;
79
+ padding: 0.4rem 0.5rem;
80
+ text-decoration: none;
81
+ }
82
+
83
+ .link:hover {
84
+ background: var(--tmc-docs-sidebar-link-hover);
85
+ color: var(--tmc-docs-sidebar-heading);
86
+ }
87
+
88
+ .linkActive {
89
+ background: var(--tmc-docs-sidebar-link-active-background);
90
+ color: var(--tmc-docs-sidebar-link-active-text);
91
+ }
92
+
93
+ .linkActive:hover {
94
+ background: var(--tmc-docs-sidebar-link-active-background);
95
+ color: var(--tmc-docs-sidebar-link-active-text);
96
+ }
97
+
98
+ .label {
99
+ overflow: hidden;
100
+ text-overflow: ellipsis;
101
+ white-space: nowrap;
102
+ }
103
+
104
+ .badge {
105
+ color: inherit;
106
+ flex: 0 0 auto;
107
+ font-size: 0.74rem;
108
+ opacity: 0.72;
109
+ }
110
+
111
+ .footer {
112
+ margin-top: 1.5rem;
113
+ }
@@ -0,0 +1,18 @@
1
+ import type { HTMLAttributes, ReactNode } from "react";
2
+ export interface DocsSidebarItem {
3
+ badge?: ReactNode;
4
+ href: string;
5
+ label: ReactNode;
6
+ }
7
+ export interface DocsSidebarGroup {
8
+ items: DocsSidebarItem[];
9
+ label: ReactNode;
10
+ }
11
+ export interface DocsSidebarProps extends Omit<HTMLAttributes<HTMLElement>, "title"> {
12
+ currentPath?: string;
13
+ footer?: ReactNode;
14
+ groups: DocsSidebarGroup[];
15
+ normalizeHref?: (href: string) => string;
16
+ title?: ReactNode;
17
+ version?: ReactNode;
18
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export { DocsSidebar } from "./DocsSidebar";
2
+ export type { DocsSidebarGroup, DocsSidebarItem, DocsSidebarProps } from "./DocsSidebar.types";
@@ -0,0 +1 @@
1
+ export { DocsSidebar } from "./DocsSidebar";
@@ -0,0 +1 @@
1
+ export * from "./docs-sidebar";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from "./docs-sidebar";
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@themodcraft/addon-docs",
3
+ "version": "1.1.0",
4
+ "publishConfig": {
5
+ "access": "public"
6
+ },
7
+ "type": "module",
8
+ "files": ["dist"],
9
+ "sideEffects": ["./dist/**/*.css"],
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "default": "./dist/index.js"
14
+ },
15
+ "./docs-sidebar": {
16
+ "types": "./dist/docs-sidebar/index.d.ts",
17
+ "default": "./dist/docs-sidebar/index.js"
18
+ }
19
+ },
20
+ "scripts": {
21
+ "build": "node ../../tools/build-package.mjs",
22
+ "prepack": "npm run build",
23
+ "typecheck": "tsc -p tsconfig.json --noEmit"
24
+ },
25
+ "dependencies": {
26
+ "@themodcraft/license-client": "1.1.0"
27
+ },
28
+ "peerDependencies": {
29
+ "react": "^19.0.0",
30
+ "react-dom": "^19.0.0"
31
+ }
32
+ }