boltdocs 2.6.2 → 2.7.1

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.
Files changed (178) hide show
  1. package/bin/boltdocs.js +0 -1
  2. package/dist/cache-CQKlT4fI.mjs +6 -0
  3. package/dist/cache-DorPMFgW.cjs +6 -0
  4. package/dist/cards-BLoSiRuL.d.ts +30 -0
  5. package/dist/cards-CQn9mXZS.d.cts +30 -0
  6. package/dist/chunk-Ds5LZdWN.cjs +6 -0
  7. package/dist/client/index.cjs +1 -1
  8. package/dist/client/index.d.cts +168 -1339
  9. package/dist/client/index.d.ts +167 -1338
  10. package/dist/client/index.js +1 -1
  11. package/dist/{package-CFP44vfn.cjs → client/mdx.cjs} +1 -1
  12. package/dist/client/mdx.d.cts +128 -0
  13. package/dist/client/mdx.d.ts +129 -0
  14. package/dist/client/mdx.js +6 -0
  15. package/dist/client/primitives.cjs +6 -0
  16. package/dist/client/primitives.d.cts +818 -0
  17. package/dist/client/primitives.d.ts +818 -0
  18. package/dist/client/primitives.js +6 -0
  19. package/dist/client/theme/neutral.css +74 -361
  20. package/dist/client/theme/reset.css +189 -0
  21. package/dist/docs-layout-BlDhcQRv.cjs +6 -0
  22. package/dist/docs-layout-BvAOWEJw.js +6 -0
  23. package/dist/doctor-BQiQhCTl.cjs +6 -0
  24. package/dist/doctor-COpf35L2.cjs +20 -0
  25. package/dist/doctor-Dh1XP7Pz.mjs +20 -0
  26. package/dist/generator-DGW6pkCC.cjs +22 -0
  27. package/dist/generator-Dv3wEmhZ.mjs +22 -0
  28. package/dist/icons-dev-CrQLjoQp.js +6 -0
  29. package/dist/icons-dev-rzdz6Lf3.cjs +6 -0
  30. package/dist/image-BkIfa9oo.js +6 -0
  31. package/dist/image-DIGjCPe6.cjs +6 -0
  32. package/dist/mdx-K0WYBAJ3.js +7 -0
  33. package/dist/mdx-hpErbRUe.cjs +7 -0
  34. package/dist/meta-loader-0gJ4PtBC.cjs +6 -0
  35. package/dist/meta-loader-9IpAHWDS.mjs +6 -0
  36. package/dist/node/cli-entry.cjs +1 -2
  37. package/dist/node/cli-entry.mjs +1 -2
  38. package/dist/node/index.cjs +1 -1
  39. package/dist/node/index.d.cts +55 -11
  40. package/dist/node/index.d.mts +55 -12
  41. package/dist/node/index.mjs +1 -1
  42. package/dist/node/routes/worker.cjs +6 -0
  43. package/dist/node/routes/worker.d.cts +2 -0
  44. package/dist/node/routes/worker.d.mts +2 -0
  45. package/dist/node/routes/worker.mjs +6 -0
  46. package/dist/node-BzKYJJuY.cjs +111 -0
  47. package/dist/node-m6fKXXVs.mjs +111 -0
  48. package/dist/{package-Bqbn1AYK.mjs → package-2TVh81ZC.mjs} +1 -1
  49. package/dist/package-D1O_gJub.cjs +6 -0
  50. package/dist/parser-Bh11BsdA.cjs +6 -0
  51. package/dist/parser-D8eQvE7N.mjs +6 -0
  52. package/dist/parser-DYRzXWmA.cjs +6 -0
  53. package/dist/routes-CHf76Ye4.cjs +6 -0
  54. package/dist/routes-CMUZGI6T.mjs +6 -0
  55. package/dist/routes-Co1mRM58.cjs +6 -0
  56. package/dist/search-dialog-BACuzoVX.cjs +6 -0
  57. package/dist/search-dialog-BKagVT17.js +6 -0
  58. package/dist/search-dialog-C8w12eUx.js +6 -0
  59. package/dist/search-dialog-CGyrozZE.cjs +6 -0
  60. package/dist/search-dialog-D26rUnJ_.cjs +6 -0
  61. package/dist/sidebar-DKvg6KOc.d.cts +491 -0
  62. package/dist/sidebar-Dr1TiRIy.d.ts +491 -0
  63. package/dist/utils-BxNAXhZZ.mjs +7 -0
  64. package/dist/utils-Clzu7jvb.cjs +7 -0
  65. package/dist/worker-pool-Bd8Y9KDv.mjs +6 -0
  66. package/dist/worker-pool-BwU8ckrg.cjs +6 -0
  67. package/package.json +27 -8
  68. package/src/client/app/doc-page.tsx +9 -5
  69. package/src/client/app/docs-layout.tsx +17 -3
  70. package/src/client/app/head.tsx +122 -0
  71. package/src/client/app/helmet-compat.tsx +36 -0
  72. package/src/client/app/mdx-component.tsx +5 -52
  73. package/src/client/app/mdx-components-context.tsx +32 -8
  74. package/src/client/app/routes-context.tsx +2 -2
  75. package/src/client/app/scroll-handler.tsx +1 -1
  76. package/src/client/app/theme-context.tsx +5 -5
  77. package/src/client/app/ui-context.tsx +42 -0
  78. package/src/client/components/docs-layout-default.tsx +85 -0
  79. package/src/client/components/icons-dev.tsx +38 -15
  80. package/src/client/components/mdx/callout.tsx +97 -0
  81. package/src/client/components/mdx/card.tsx +73 -98
  82. package/src/client/components/mdx/cards.tsx +27 -0
  83. package/src/client/components/mdx/code-block.tsx +37 -17
  84. package/src/client/components/mdx/field.tsx +24 -56
  85. package/src/client/components/mdx/image.tsx +36 -15
  86. package/src/client/components/mdx/index.ts +19 -53
  87. package/src/client/components/mdx/table.tsx +46 -148
  88. package/src/client/components/mdx/typographics.tsx +120 -0
  89. package/src/client/components/mdx/{hooks/use-code-block.ts → use-code-block.ts} +5 -7
  90. package/src/client/components/primitives/breadcrumbs.tsx +5 -24
  91. package/src/client/components/primitives/button.tsx +3 -142
  92. package/src/client/components/primitives/code-block.tsx +104 -97
  93. package/src/client/components/{docs-layout.tsx → primitives/docs-layout.tsx} +15 -24
  94. package/src/client/components/primitives/error-boundary.tsx +107 -0
  95. package/src/client/components/primitives/heading.tsx +128 -0
  96. package/src/client/components/primitives/helpers/observer.ts +62 -32
  97. package/src/client/components/primitives/image.tsx +26 -0
  98. package/src/client/components/primitives/link.tsx +50 -52
  99. package/src/client/components/primitives/menu.tsx +25 -49
  100. package/src/client/components/primitives/navbar.tsx +234 -59
  101. package/src/client/components/primitives/on-this-page.tsx +169 -40
  102. package/src/client/components/primitives/page-nav.tsx +11 -39
  103. package/src/client/components/primitives/popover.tsx +12 -30
  104. package/src/client/components/primitives/search-dialog.tsx +77 -71
  105. package/src/client/components/primitives/sidebar.tsx +312 -119
  106. package/src/client/components/primitives/skeleton.tsx +1 -1
  107. package/src/client/components/primitives/tabs.tsx +5 -16
  108. package/src/client/components/primitives/tooltip.tsx +1 -1
  109. package/src/client/components/ui-base/banner.tsx +66 -0
  110. package/src/client/components/ui-base/breadcrumbs.tsx +26 -20
  111. package/src/client/components/ui-base/copy-markdown.tsx +43 -35
  112. package/src/client/components/ui-base/error-boundary.tsx +9 -46
  113. package/src/client/components/ui-base/github-stars.tsx +5 -3
  114. package/src/client/components/ui-base/index.ts +3 -3
  115. package/src/client/components/ui-base/last-updated.tsx +27 -0
  116. package/src/client/components/ui-base/navbar.tsx +183 -89
  117. package/src/client/components/ui-base/not-found.tsx +11 -9
  118. package/src/client/components/ui-base/on-this-page.tsx +8 -104
  119. package/src/client/components/ui-base/page-nav.tsx +23 -9
  120. package/src/client/components/ui-base/search-dialog.tsx +111 -36
  121. package/src/client/components/ui-base/search-highlight.tsx +10 -0
  122. package/src/client/components/ui-base/sidebar.tsx +77 -154
  123. package/src/client/components/ui-base/tabs.tsx +20 -7
  124. package/src/client/components/ui-base/theme-toggle.tsx +88 -10
  125. package/src/client/components/ui-base/version-i18n.tsx +80 -0
  126. package/src/client/hooks/index.ts +2 -1
  127. package/src/client/hooks/use-analytics.ts +272 -0
  128. package/src/client/hooks/use-i18n.ts +116 -50
  129. package/src/client/hooks/use-localized-to.ts +70 -27
  130. package/src/client/hooks/use-navbar.ts +69 -39
  131. package/src/client/hooks/use-page-nav.ts +28 -25
  132. package/src/client/hooks/use-routes.ts +63 -80
  133. package/src/client/hooks/use-search-highlight.ts +185 -0
  134. package/src/client/hooks/use-search.ts +12 -3
  135. package/src/client/hooks/use-sidebar.ts +183 -80
  136. package/src/client/hooks/use-tabs.ts +3 -4
  137. package/src/client/hooks/use-version.ts +44 -29
  138. package/src/client/index.ts +13 -87
  139. package/src/client/mdx.ts +2 -0
  140. package/src/client/primitives.ts +19 -0
  141. package/src/client/ssg/boltdocs-shell.tsx +68 -79
  142. package/src/client/ssg/create-routes.tsx +268 -72
  143. package/src/client/ssg/index.ts +1 -0
  144. package/src/client/ssg/mdx-page.tsx +2 -1
  145. package/src/client/store/boltdocs-context.tsx +72 -20
  146. package/src/client/theme/neutral.css +74 -361
  147. package/src/client/theme/reset.css +189 -0
  148. package/src/client/types.ts +10 -2
  149. package/src/client/utils/path.ts +9 -0
  150. package/src/client/utils/react-to-text.ts +24 -24
  151. package/src/client/virtual.d.ts +1 -1
  152. package/src/shared/types.ts +82 -22
  153. package/dist/node-Bogvkxao.mjs +0 -101
  154. package/dist/node-CXaog6St.cjs +0 -101
  155. package/dist/search-dialog-CV3eJzMm.cjs +0 -6
  156. package/dist/search-dialog-DNTomKgu.js +0 -6
  157. package/dist/use-search-CS3gH19M.js +0 -6
  158. package/dist/use-search-DBpJZQuw.cjs +0 -6
  159. package/src/client/components/mdx/admonition.tsx +0 -91
  160. package/src/client/components/mdx/badge.tsx +0 -41
  161. package/src/client/components/mdx/button.tsx +0 -35
  162. package/src/client/components/mdx/component-preview.tsx +0 -37
  163. package/src/client/components/mdx/component-props.tsx +0 -83
  164. package/src/client/components/mdx/file-tree.tsx +0 -325
  165. package/src/client/components/mdx/hooks/use-component-preview.ts +0 -16
  166. package/src/client/components/mdx/hooks/useTable.ts +0 -74
  167. package/src/client/components/mdx/hooks/useTabs.ts +0 -68
  168. package/src/client/components/mdx/link.tsx +0 -38
  169. package/src/client/components/mdx/list.tsx +0 -192
  170. package/src/client/components/mdx/tabs.tsx +0 -135
  171. package/src/client/components/mdx/video.tsx +0 -68
  172. package/src/client/components/primitives/index.ts +0 -19
  173. package/src/client/components/primitives/navigation-menu.tsx +0 -114
  174. package/src/client/components/ui-base/head.tsx +0 -83
  175. package/src/client/components/ui-base/loading.tsx +0 -57
  176. package/src/client/components/ui-base/powered-by.tsx +0 -25
  177. package/src/client/hooks/use-onthispage.ts +0 -23
  178. package/src/client/utils/use-on-change.ts +0 -15
@@ -1,53 +1,19 @@
1
- export { Button } from './button'
2
- export type { ButtonProps } from './button'
3
-
4
- export { CodeBlock } from './code-block'
5
-
6
- export { Tabs, Tab } from './tabs'
7
- export type { TabsProps, TabProps } from './tabs'
8
-
9
- export { Video } from './video'
10
-
11
- export { Badge } from './badge'
12
- export type { BadgeProps } from './badge'
13
-
14
- export { Card, Cards } from './card'
15
- export type { CardProps, CardsProps } from './card'
16
-
17
- export {
18
- Admonition,
19
- Note,
20
- Tip,
21
- Warning,
22
- Danger,
23
- InfoBox,
24
- Important,
25
- Caution,
26
- } from './admonition'
27
- export type { AdmonitionProps } from './admonition'
28
-
29
- export { List } from './list'
30
- export type { ListProps } from './list'
31
-
32
- export { FileTree } from './file-tree'
33
- export type { FileTreeProps } from './file-tree'
34
-
35
- export { Table } from './table'
36
- export type { TableProps } from './table'
37
-
38
- export { Field } from './field'
39
- export type { FieldProps } from './field'
40
-
41
- export { Link } from './link'
42
- export type { LinkProps } from './link'
43
-
44
- export { Image } from './image'
45
- export type { ImageProps } from './image'
46
-
47
- export { ComponentProps } from './component-props'
48
- export type { ComponentPropsProps } from './component-props'
49
-
50
- export { ComponentPreview } from './component-preview'
51
- export type { ComponentPreviewProps } from './component-preview'
52
- export { CopyMarkdown } from '../ui-base/copy-markdown'
53
- export type { CopyMarkdownProps } from '../ui-base/copy-markdown'
1
+ import { Field } from './field'
2
+ import { Typographics } from './typographics'
3
+ import { TableComponents } from './table'
4
+ import { Callout } from './callout'
5
+ import { CodeBlock } from './code-block'
6
+ import { ImageComponents } from './image'
7
+ import { Card } from './card'
8
+ import { Cards } from './cards'
9
+
10
+ export const mdx_components_default = {
11
+ ...Typographics,
12
+ ...TableComponents,
13
+ ...ImageComponents,
14
+ pre: CodeBlock,
15
+ Field,
16
+ Callout,
17
+ Card,
18
+ Cards,
19
+ }
@@ -1,156 +1,54 @@
1
- import * as RAC from 'react-aria-components'
2
- import { useTable } from './hooks/useTable'
3
- import {
4
- ChevronUp,
5
- ChevronDown,
6
- ChevronLeft,
7
- ChevronRight,
8
- ChevronsLeft,
9
- ChevronsRight,
10
- } from 'lucide-react'
11
1
  import { cn } from '../../utils/cn'
12
2
 
13
- export interface TableProps {
14
- headers?: string[]
15
- data?: (string | React.ReactNode)[][]
16
- children?: React.ReactNode
17
- className?: string
18
- sortable?: boolean
19
- paginated?: boolean
20
- pageSize?: number
21
- }
3
+ const Table = (props: React.HTMLAttributes<HTMLTableElement>) => (
4
+ <div className="my-6 w-full overflow-x-auto rounded-xl border border-subtle bg-surface/30">
5
+ <table className="w-full border-collapse text-left text-sm" {...props} />
6
+ </div>
7
+ )
8
+
9
+ const TableHead = (props: React.HTMLAttributes<HTMLTableSectionElement>) => (
10
+ <thead
11
+ className={cn('border-b border-subtle bg-soft/50', props.className)}
12
+ {...props}
13
+ />
14
+ )
22
15
 
23
- export function Table({
24
- headers,
25
- data,
26
- children,
27
- className = '',
28
- sortable = false,
29
- paginated = false,
30
- pageSize = 10,
31
- }: TableProps) {
32
- const {
33
- sortConfig,
34
- currentPage,
35
- setCurrentPage,
36
- totalPages,
37
- paginatedData,
38
- requestSort,
39
- } = useTable({
40
- data,
41
- sortable,
42
- paginated,
43
- pageSize,
44
- })
16
+ const TableBody = (props: React.HTMLAttributes<HTMLTableSectionElement>) => (
17
+ <tbody {...props} />
18
+ )
45
19
 
46
- const renderSortIcon = (index: number) => {
47
- if (!sortable) return null
48
- if (sortConfig?.key !== index)
49
- return <ChevronDown size={14} className="ml-1 opacity-30" />
50
- return sortConfig.direction === 'asc' ? (
51
- <ChevronUp size={14} className="ml-1 text-primary-400" />
52
- ) : (
53
- <ChevronDown size={14} className="ml-1 text-primary-400" />
54
- )
55
- }
20
+ const TableRow = (props: React.HTMLAttributes<HTMLTableRowElement>) => (
21
+ <tr
22
+ className={cn(
23
+ 'border-b border-subtle last:border-0 even:bg-soft/10 hover:bg-soft/20 transition-colors',
24
+ props.className,
25
+ )}
26
+ {...props}
27
+ />
28
+ )
56
29
 
57
- const tableContent = children ? (
58
- children
59
- ) : (
60
- <>
61
- {headers && (
62
- <thead>
63
- <tr>
64
- {headers.map((header, i) => (
65
- <th
66
- key={i}
67
- onClick={() => requestSort(i)}
68
- className={cn(
69
- 'text-left px-3 py-2.5 border-b-2 border-border-subtle text-text-main font-semibold text-sm',
70
- sortable &&
71
- 'cursor-pointer select-none hover:text-primary-400 transition-colors',
72
- )}
73
- >
74
- <div className="flex items-center">
75
- {header}
76
- {renderSortIcon(i)}
77
- </div>
78
- </th>
79
- ))}
80
- </tr>
81
- </thead>
82
- )}
83
- {paginatedData && (
84
- <tbody>
85
- {paginatedData.map((row, i) => (
86
- <tr key={i} className="transition-colors hover:bg-bg-surface">
87
- {row.map((cell, j) => (
88
- <td
89
- key={j}
90
- className="px-3 py-2 border-b border-border-subtle text-sm text-text-muted"
91
- >
92
- {cell}
93
- </td>
94
- ))}
95
- </tr>
96
- ))}
97
- </tbody>
98
- )}
99
- </>
100
- )
30
+ const TableHeader = (props: React.HTMLAttributes<HTMLTableCellElement>) => (
31
+ <th
32
+ className={cn(
33
+ 'px-4 py-3 font-semibold text-body text-xs font-mono',
34
+ props.className,
35
+ )}
36
+ {...props}
37
+ />
38
+ )
101
39
 
102
- return (
103
- <div
104
- className={cn(
105
- 'my-6 rounded-lg border border-border-subtle overflow-hidden',
106
- className,
107
- )}
108
- >
109
- <div className="overflow-x-auto">
110
- <table className="w-full border-collapse text-sm">{tableContent}</table>
111
- </div>
40
+ const TableCell = (props: React.HTMLAttributes<HTMLTableCellElement>) => (
41
+ <td
42
+ className={cn('px-4 py-3 text-paragraph leading-relaxed', props.className)}
43
+ {...props}
44
+ />
45
+ )
112
46
 
113
- {paginated && totalPages > 1 && (
114
- <div className="flex items-center justify-between border-t border-border-subtle px-4 py-3">
115
- <span className="text-xs text-text-muted">
116
- Page {currentPage} of {totalPages}
117
- </span>
118
- <div className="flex items-center gap-1">
119
- <RAC.Button
120
- onPress={() => setCurrentPage(1)}
121
- isDisabled={currentPage === 1}
122
- className="grid place-items-center h-7 w-7 rounded-md text-text-muted outline-none transition-colors hover:bg-bg-surface disabled:opacity-30 disabled:pointer-events-none cursor-pointer"
123
- >
124
- <ChevronsLeft size={16} />
125
- </RAC.Button>
126
- <RAC.Button
127
- onPress={() =>
128
- setCurrentPage((prev: number) => Math.max(prev - 1, 1))
129
- }
130
- isDisabled={currentPage === 1}
131
- className="grid place-items-center h-7 w-7 rounded-md text-text-muted outline-none transition-colors hover:bg-bg-surface disabled:opacity-30 disabled:pointer-events-none cursor-pointer"
132
- >
133
- <ChevronLeft size={16} />
134
- </RAC.Button>
135
- <RAC.Button
136
- onPress={() =>
137
- setCurrentPage((prev: number) => Math.min(prev + 1, totalPages))
138
- }
139
- isDisabled={currentPage === totalPages}
140
- className="grid place-items-center h-7 w-7 rounded-md text-text-muted outline-none transition-colors hover:bg-bg-surface disabled:opacity-30 disabled:pointer-events-none cursor-pointer"
141
- >
142
- <ChevronRight size={16} />
143
- </RAC.Button>
144
- <RAC.Button
145
- onPress={() => setCurrentPage(totalPages)}
146
- isDisabled={currentPage === totalPages}
147
- className="grid place-items-center h-7 w-7 rounded-md text-text-muted outline-none transition-colors hover:bg-bg-surface disabled:opacity-30 disabled:pointer-events-none cursor-pointer"
148
- >
149
- <ChevronsRight size={16} />
150
- </RAC.Button>
151
- </div>
152
- </div>
153
- )}
154
- </div>
155
- )
47
+ export const TableComponents = {
48
+ table: Table,
49
+ thead: TableHead,
50
+ tbody: TableBody,
51
+ tr: TableRow,
52
+ th: TableHeader,
53
+ td: TableCell,
156
54
  }
@@ -0,0 +1,120 @@
1
+ import { Link } from '../primitives/link'
2
+ import { cn } from '../../utils/cn'
3
+ import { Heading as HeadingPrimitive } from '../primitives/heading'
4
+
5
+ const Anchor = ({
6
+ href,
7
+ children,
8
+ className,
9
+ ...props
10
+ }: React.AnchorHTMLAttributes<HTMLAnchorElement>) => {
11
+ return (
12
+ <Link
13
+ href={href || ''}
14
+ className={cn(
15
+ 'text-primary-500 hover:text-primary-400 dark:text-primary-500 hover:underline font-medium transition-colors duration-200',
16
+ className,
17
+ )}
18
+ {...props}
19
+ >
20
+ {children}
21
+ </Link>
22
+ )
23
+ }
24
+
25
+ const HEADING_CLASSES: Record<number, string> = {
26
+ 1: 'text-3xl sm:text-[2.5rem] font-extrabold tracking-tight text-body mb-4 leading-tight',
27
+ 2: 'text-2xl sm:text-[1.75rem] font-bold tracking-tight text-body mt-14 mb-5 pb-2 border-b border-subtle scroll-mt-24',
28
+ 3: 'text-lg sm:text-[1.4rem] font-semibold tracking-tight text-body mt-10 mb-4 scroll-mt-24',
29
+ 4: 'text-base sm:text-[1.1rem] font-semibold tracking-tight text-body mt-8 mb-3 scroll-mt-24',
30
+ 5: 'text-sm sm:text-[0.9rem] font-semibold tracking-tight text-body mt-6 mb-2 scroll-mt-24',
31
+ 6: 'text-xs sm:text-[0.75rem] font-semibold tracking-tight text-body mt-6 mb-2 scroll-mt-24',
32
+ }
33
+
34
+ const Heading = ({
35
+ level,
36
+ className,
37
+ ...props
38
+ }: React.ComponentProps<typeof HeadingPrimitive>) => {
39
+ const headingClass = HEADING_CLASSES[level] || ''
40
+ return (
41
+ <HeadingPrimitive
42
+ level={level}
43
+ className={cn(headingClass, className)}
44
+ {...props}
45
+ />
46
+ )
47
+ }
48
+
49
+ export const Typographics = {
50
+ a: Anchor,
51
+ h1: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
52
+ <Heading level={1} {...props} />
53
+ ),
54
+ h2: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
55
+ <Heading level={2} {...props} />
56
+ ),
57
+ h3: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
58
+ <Heading level={3} {...props} />
59
+ ),
60
+ h4: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
61
+ <Heading level={4} {...props} />
62
+ ),
63
+ h5: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
64
+ <Heading level={5} {...props} />
65
+ ),
66
+ h6: (props: React.HTMLAttributes<HTMLHeadingElement>) => (
67
+ <Heading level={6} {...props} />
68
+ ),
69
+ p: ({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) => (
70
+ <p
71
+ className={cn('text-paragraph leading-relaxed my-5', className)}
72
+ {...props}
73
+ />
74
+ ),
75
+ strong: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
76
+ <strong className={cn('font-semibold text-body', className)} {...props} />
77
+ ),
78
+ mark: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
79
+ <mark
80
+ className={cn(
81
+ 'bg-primary-500/10 text-primary-500 font-semibold px-1.5 py-0.5 rounded-md',
82
+ className,
83
+ )}
84
+ {...props}
85
+ />
86
+ ),
87
+ blockquote: ({
88
+ className,
89
+ ...props
90
+ }: React.HTMLAttributes<HTMLQuoteElement>) => (
91
+ <blockquote
92
+ className={cn(
93
+ 'border-l-4 border-primary-500 bg-soft/30 pl-4 py-2 my-6 italic text-muted rounded-r-lg',
94
+ className,
95
+ )}
96
+ {...props}
97
+ />
98
+ ),
99
+ hr: ({ className, ...props }: React.HTMLAttributes<HTMLHRElement>) => (
100
+ <hr className={cn('my-8 border-t border-subtle', className)} {...props} />
101
+ ),
102
+ ul: ({ className, ...props }: React.HTMLAttributes<HTMLUListElement>) => (
103
+ <ul
104
+ className={cn('list-disc pl-6 my-5 space-y-2 text-paragraph', className)}
105
+ {...props}
106
+ />
107
+ ),
108
+ ol: ({ className, ...props }: React.HTMLAttributes<HTMLOListElement>) => (
109
+ <ol
110
+ className={cn(
111
+ 'list-decimal pl-6 my-5 space-y-2 text-paragraph',
112
+ className,
113
+ )}
114
+ {...props}
115
+ />
116
+ ),
117
+ li: ({ className, ...props }: React.HTMLAttributes<HTMLLIElement>) => (
118
+ <li className={cn('pl-1', className)} {...props} />
119
+ ),
120
+ }
@@ -1,15 +1,12 @@
1
- import { useConfig } from '../../../app/config-context'
2
- import { copyToClipboard } from '../../../utils/copy-clipboard'
1
+ import { copyToClipboard } from '../../utils/copy-clipboard'
3
2
  import { useCallback, useEffect, useRef, useState } from 'react'
4
- import type { CodeBlockProps } from '../code-block'
3
+ import type { CodeBlockProps } from './code-block'
5
4
 
6
5
  export function useCodeBlock(props: CodeBlockProps) {
7
- const { title } = props
8
6
  const [copied, setCopied] = useState(false)
9
7
  const [isExpanded, setIsExpanded] = useState(false)
10
8
  const [isExpandable, setIsExpandable] = useState(false)
11
9
  const preRef = useRef<HTMLPreElement>(null)
12
- const config = useConfig()
13
10
 
14
11
  const handleCopy = useCallback(async () => {
15
12
  const code = preRef.current?.textContent ?? ''
@@ -20,8 +17,9 @@ export function useCodeBlock(props: CodeBlockProps) {
20
17
 
21
18
  // biome-ignore lint/correctness/useExhaustiveDependencies: updates when content changes
22
19
  useEffect(() => {
23
- const codeLength = preRef.current?.textContent?.length ?? 0
24
- setIsExpandable(codeLength > 120)
20
+ const code = preRef.current?.textContent ?? ''
21
+ const lines = code.trim().split('\n').length
22
+ setIsExpandable(lines > 6)
25
23
  }, [props.children, props.highlightedHtml])
26
24
 
27
25
  return {
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  Breadcrumb,
3
3
  Breadcrumbs as BreadcrumbsRAC,
4
- Link,
5
4
  } from 'react-aria-components'
5
+ import { Link } from './link'
6
6
  import type { LinkProps } from 'react-aria-components'
7
7
  import { ChevronRight } from 'lucide-react'
8
8
  import { cn } from '../../utils/cn'
@@ -15,10 +15,7 @@ export const Breadcrumbs = ({
15
15
  }: ComponentBase) => {
16
16
  return (
17
17
  <BreadcrumbsRAC
18
- className={cn(
19
- 'flex items-center gap-1.5 pl-0! mb-0 text-sm text-text-muted',
20
- className,
21
- )}
18
+ className={cn('flex flex-wrap items-center', className)}
22
19
  {...props}
23
20
  >
24
21
  {children as any}
@@ -28,10 +25,7 @@ export const Breadcrumbs = ({
28
25
 
29
26
  const BreadcrumbsItem = ({ children, className, ...props }: ComponentBase) => {
30
27
  return (
31
- <Breadcrumb
32
- className={cn('flex items-center mb-0 gap-1.5', className)}
33
- {...props}
34
- >
28
+ <Breadcrumb className={cn('flex items-center', className)} {...props}>
35
29
  {children as any}
36
30
  </Breadcrumb>
37
31
  )
@@ -44,27 +38,14 @@ const BreadcrumbsLink = ({
44
38
  ...props
45
39
  }: LinkProps & { className?: string }) => {
46
40
  return (
47
- <Link
48
- href={href}
49
- className={cn(
50
- 'transition-colors outline-none hover:text-text-main focus-visible:ring-2 focus-visible:ring-primary-500/30 rounded-sm',
51
- 'current:font-medium current:text-text-main current:pointer-events-none cursor-pointer',
52
- className,
53
- )}
54
- {...props}
55
- >
41
+ <Link href={href} className={cn('cursor-pointer', className)} {...props}>
56
42
  {children as any}
57
43
  </Link>
58
44
  )
59
45
  }
60
46
 
61
47
  const BreadcrumbsSeparator = ({ className }: ComponentBase) => {
62
- return (
63
- <ChevronRight
64
- size={14}
65
- className={cn('shrink-0 text-text-dim', className)}
66
- />
67
- )
48
+ return <ChevronRight size={14} className={cn('shrink-0', className)} />
68
49
  }
69
50
 
70
51
  Breadcrumbs.Root = Breadcrumbs
@@ -1,145 +1,6 @@
1
1
  import * as RAC from 'react-aria-components'
2
- import { cn } from '../../utils/cn'
3
- import { cva } from 'class-variance-authority'
4
- import type { VariantProps } from 'class-variance-authority'
2
+ export interface ButtonProps extends RAC.ButtonProps {}
5
3
 
6
- export const buttonVariants = cva(
7
- 'flex flex-row items-center justify-center w-auto font-semibold tracking-tight no-underline whitespace-nowrap select-none outline-none transition-all duration-200 cursor-pointer pressed:scale-[0.97] hover:-translate-y-px leading-none',
8
- {
9
- variants: {
10
- variant: {
11
- primary:
12
- 'bg-primary-500 text-white shadow-md hover:brightness-110 hover:shadow-lg',
13
- secondary:
14
- 'bg-bg-surface text-text-main border border-border-subtle hover:bg-bg-muted hover:border-border-strong',
15
- outline:
16
- 'bg-transparent text-text-main border border-border-strong hover:bg-bg-surface hover:border-primary-500',
17
- ghost:
18
- 'bg-transparent text-text-muted hover:bg-bg-surface hover:text-text-main',
19
- danger:
20
- 'bg-[var(--color-danger-500)]/10 text-[var(--color-danger-500)] border border-[var(--color-danger-500)]/20 hover:bg-[var(--color-danger-500)]/15',
21
- success:
22
- 'bg-[var(--color-success-500)]/10 text-[var(--color-success-500)] border border-[var(--color-success-500)]/20 hover:bg-[var(--color-success-500)]/15',
23
- warning:
24
- 'bg-[var(--color-warning-500)]/10 text-[var(--color-warning-500)] border border-[var(--color-warning-500)]/20 hover:bg-[var(--color-warning-500)]/15',
25
- info: 'bg-[var(--color-info-500)]/10 text-[var(--color-info-500)] border border-[var(--color-info-500)]/20 hover:bg-[var(--color-info-500)]/15',
26
- subtle: 'bg-primary-500/10 text-primary-500 hover:bg-primary-500/20',
27
- link: 'bg-transparent text-primary-500 !p-0 !min-h-0 hover:underline',
28
- },
29
- size: {
30
- sm: 'min-h-8 px-3.5 text-[0.8125rem] gap-1.5',
31
- md: 'min-h-10 px-5 text-[0.9375rem] gap-2',
32
- lg: 'min-h-12 px-7 text-[1.05rem] gap-2.5',
33
- },
34
- rounded: {
35
- none: 'rounded-none',
36
- sm: 'rounded-sm',
37
- md: 'rounded-md',
38
- lg: 'rounded-lg',
39
- full: 'rounded-full',
40
- },
41
- iconSize: {
42
- sm: 'w-8 h-8 p-0',
43
- md: 'w-10 h-10 p-0',
44
- lg: 'w-12 h-12 p-0',
45
- },
46
- disabled: {
47
- true: 'opacity-50 cursor-not-allowed pointer-events-none',
48
- false: null,
49
- },
50
- },
51
- defaultVariants: {
52
- variant: 'primary',
53
- size: 'md',
54
- rounded: 'md',
55
- },
56
- },
57
- )
58
- type ButtonVariantType = VariantProps<typeof buttonVariants>
59
-
60
- export interface ButtonProps
61
- extends Omit<RAC.ButtonProps, 'children' | 'className'>,
62
- ButtonVariantType {
63
- icon?: React.ReactNode
64
- iconPosition?: 'left' | 'right'
65
- href?: string
66
- children?: React.ReactNode
67
- className?: string
68
- isIconOnly?: boolean
69
- }
70
-
71
- export const Button = ({
72
- href,
73
- icon,
74
- iconPosition = 'left',
75
- isIconOnly,
76
- children,
77
- className,
78
- variant,
79
- size,
80
- rounded,
81
- iconSize,
82
- disabled,
83
- ...props
84
- }: ButtonProps) => {
85
- const isOnlyIcon = isIconOnly || (!children && !!icon)
86
-
87
- const content = isOnlyIcon ? (
88
- <span className="inline-flex items-center justify-center [&>svg]:w-[1.2rem] [&>svg]:h-[1.2rem]">
89
- {icon}
90
- </span>
91
- ) : (
92
- <>
93
- {icon && iconPosition === 'left' && (
94
- <span className="inline-flex items-center shrink-0 [&>svg]:w-[1.1rem] [&>svg]:h-[1.1rem]">
95
- {icon}
96
- </span>
97
- )}
98
- <span className="flex items-center">{children}</span>
99
- {icon && iconPosition === 'right' && (
100
- <span className="inline-flex items-center shrink-0 [&>svg]:w-[1.1rem] [&>svg]:h-[1.1rem]">
101
- {icon}
102
- </span>
103
- )}
104
- </>
105
- )
106
-
107
- if (href) {
108
- return (
109
- <RAC.Link
110
- href={href}
111
- className={cn(
112
- buttonVariants({
113
- variant,
114
- size,
115
- rounded,
116
- iconSize: isOnlyIcon ? iconSize : undefined,
117
- disabled,
118
- }),
119
- className,
120
- )}
121
- {...(props as RAC.LinkProps)}
122
- >
123
- {content}
124
- </RAC.Link>
125
- )
126
- }
127
-
128
- return (
129
- <RAC.Button
130
- className={cn(
131
- buttonVariants({
132
- variant,
133
- size,
134
- rounded,
135
- iconSize: isOnlyIcon ? iconSize : undefined,
136
- disabled,
137
- }),
138
- className,
139
- )}
140
- {...(props as RAC.ButtonProps)}
141
- >
142
- {content}
143
- </RAC.Button>
144
- )
4
+ export const Button = ({ ...props }: ButtonProps) => {
5
+ return <RAC.Button {...props} />
145
6
  }