@terrafirmagreg-team/ui 0.0.0-stage → 0.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/package.json +93 -3
- package/src/components/blocks/button/icon-button.tsx +48 -0
- package/src/components/blocks/canvas/chevron-edge.tsx +134 -0
- package/src/components/blocks/canvas/flow-canvas.tsx +177 -0
- package/src/components/blocks/canvas/flow-toolbar.tsx +32 -0
- package/src/components/blocks/canvas/flow-viewport.tsx +243 -0
- package/src/components/blocks/git/github-info.tsx +77 -0
- package/src/components/blocks/lang/content.tsx +22 -0
- package/src/components/blocks/lang/flag.tsx +24 -0
- package/src/components/blocks/lang/link.tsx +22 -0
- package/src/components/blocks/lang/redirect.tsx +47 -0
- package/src/components/blocks/lang/switcher.tsx +53 -0
- package/src/components/blocks/lang/untranslated-callout.tsx +28 -0
- package/src/components/blocks/link/link-preview.tsx +256 -0
- package/src/components/blocks/list/row.tsx +91 -0
- package/src/components/blocks/media/glb/model.tsx +243 -0
- package/src/components/blocks/media/glb/scene.tsx +372 -0
- package/src/components/blocks/media/glb/viewer.tsx +51 -0
- package/src/components/blocks/media/image.tsx +135 -0
- package/src/components/blocks/media/slideshow.tsx +177 -0
- package/src/components/blocks/nav/breadcrumb.tsx +50 -0
- package/src/components/blocks/nav/link.tsx +85 -0
- package/src/components/blocks/nav/site-menu.tsx +77 -0
- package/src/components/blocks/nav/site-title.tsx +60 -0
- package/src/components/blocks/nav/switcher.tsx +205 -0
- package/src/components/blocks/page/empty-state.tsx +31 -0
- package/src/components/blocks/page/heading.tsx +53 -0
- package/src/components/blocks/page/pager.tsx +112 -0
- package/src/components/blocks/readability/menu.tsx +431 -0
- package/src/components/blocks/readability/track.tsx +164 -0
- package/src/components/blocks/search/command.tsx +79 -0
- package/src/components/blocks/search/dialog.tsx +712 -0
- package/src/components/blocks/search/provider.tsx +117 -0
- package/src/components/blocks/sidebar.tsx +406 -0
- package/src/components/blocks/theme/toggle.tsx +71 -0
- package/src/components/blocks/tooltip/hint.tsx +27 -0
- package/src/components/blocks/viewer/controls.tsx +279 -0
- package/src/components/blocks/viewer/float-bar.tsx +50 -0
- package/src/components/layouts/layout.tsx +93 -0
- package/src/components/layouts/left-sidebar/content.tsx +62 -0
- package/src/components/layouts/left-sidebar/context.tsx +54 -0
- package/src/components/layouts/left-sidebar/expand.tsx +22 -0
- package/src/components/layouts/left-sidebar/footer.tsx +105 -0
- package/src/components/layouts/left-sidebar/index.ts +28 -0
- package/src/components/layouts/left-sidebar/items.tsx +102 -0
- package/src/components/layouts/left-sidebar/search.tsx +74 -0
- package/src/components/layouts/left-sidebar/sidebar.tsx +188 -0
- package/src/components/layouts/left-sidebar/tree.tsx +156 -0
- package/src/components/layouts/right-sidebar.tsx +95 -0
- package/src/components/layouts/tree-context.tsx +41 -0
- package/src/components/mdx/accordion.tsx +184 -0
- package/src/components/mdx/banner.tsx +154 -0
- package/src/components/mdx/callout.tsx +96 -0
- package/src/components/mdx/card.tsx +49 -0
- package/src/components/mdx/codeblock.tsx +249 -0
- package/src/components/mdx/collapsible.tsx +32 -0
- package/src/components/mdx/files.tsx +62 -0
- package/src/components/mdx/glow-header.tsx +40 -0
- package/src/components/mdx/gradient-text.tsx +27 -0
- package/src/components/mdx/image-zoom.tsx +314 -0
- package/src/components/mdx/mermaid.tsx +16 -0
- package/src/components/mdx/multiblock.tsx +18 -0
- package/src/components/mdx/preview.tsx +100 -0
- package/src/components/mdx/steps.tsx +9 -0
- package/src/components/mdx/table.tsx +13 -0
- package/src/components/mdx/tabs.tsx +353 -0
- package/src/components/mdx/type-table.tsx +170 -0
- package/src/components/ui/accordion.tsx +71 -0
- package/src/components/ui/alert-dialog.tsx +187 -0
- package/src/components/ui/alert.tsx +75 -0
- package/src/components/ui/aspect-ratio.tsx +22 -0
- package/src/components/ui/attachment.tsx +207 -0
- package/src/components/ui/avatar.tsx +108 -0
- package/src/components/ui/badge.tsx +51 -0
- package/src/components/ui/breadcrumb.tsx +124 -0
- package/src/components/ui/bubble.tsx +127 -0
- package/src/components/ui/button-group.tsx +87 -0
- package/src/components/ui/button.tsx +57 -0
- package/src/components/ui/calendar.tsx +221 -0
- package/src/components/ui/card.tsx +102 -0
- package/src/components/ui/carousel.tsx +242 -0
- package/src/components/ui/chart.tsx +371 -0
- package/src/components/ui/checkbox.tsx +28 -0
- package/src/components/ui/collapsible.tsx +21 -0
- package/src/components/ui/combobox.tsx +297 -0
- package/src/components/ui/command.tsx +198 -0
- package/src/components/ui/context-menu.tsx +270 -0
- package/src/components/ui/dialog.tsx +160 -0
- package/src/components/ui/direction.tsx +6 -0
- package/src/components/ui/drawer.tsx +227 -0
- package/src/components/ui/dropdown-menu.tsx +269 -0
- package/src/components/ui/empty.tsx +103 -0
- package/src/components/ui/field.tsx +238 -0
- package/src/components/ui/hover-card.tsx +50 -0
- package/src/components/ui/input-group.tsx +158 -0
- package/src/components/ui/input-otp.tsx +86 -0
- package/src/components/ui/input.tsx +19 -0
- package/src/components/ui/item.tsx +201 -0
- package/src/components/ui/kbd.tsx +26 -0
- package/src/components/ui/label.tsx +19 -0
- package/src/components/ui/marker.tsx +70 -0
- package/src/components/ui/menubar.tsx +280 -0
- package/src/components/ui/message-scroller.tsx +131 -0
- package/src/components/ui/message.tsx +91 -0
- package/src/components/ui/native-select.tsx +60 -0
- package/src/components/ui/navigation-menu.tsx +167 -0
- package/src/components/ui/pagination.tsx +130 -0
- package/src/components/ui/popover.tsx +91 -0
- package/src/components/ui/progress.tsx +82 -0
- package/src/components/ui/questionnaire.tsx +324 -0
- package/src/components/ui/radio-group.tsx +37 -0
- package/src/components/ui/resizable.tsx +49 -0
- package/src/components/ui/scroll-area.tsx +54 -0
- package/src/components/ui/select.tsx +200 -0
- package/src/components/ui/separator.tsx +24 -0
- package/src/components/ui/sheet.tsx +138 -0
- package/src/components/ui/sidebar.tsx +730 -0
- package/src/components/ui/skeleton.tsx +13 -0
- package/src/components/ui/slider.tsx +51 -0
- package/src/components/ui/spinner.tsx +10 -0
- package/src/components/ui/switch.tsx +31 -0
- package/src/components/ui/table.tsx +115 -0
- package/src/components/ui/tabs.tsx +81 -0
- package/src/components/ui/textarea.tsx +17 -0
- package/src/components/ui/toast.tsx +234 -0
- package/src/components/ui/toggle-group.tsx +89 -0
- package/src/components/ui/toggle.tsx +44 -0
- package/src/components/ui/tooltip.tsx +65 -0
- package/src/hooks/canvas/use-flow-hover.ts +18 -0
- package/src/hooks/canvas/use-flow-viewport-persist.ts +33 -0
- package/src/hooks/lang.ts +8 -0
- package/src/hooks/layout.ts +18 -0
- package/src/hooks/page/use-fit-pages.ts +91 -0
- package/src/hooks/page/use-location-search.ts +25 -0
- package/src/hooks/page/use-page-preview.ts +40 -0
- package/src/hooks/page/use-paged-list.ts +20 -0
- package/src/hooks/readability/provider.ts +86 -0
- package/src/hooks/search/dialog.ts +41 -0
- package/src/hooks/search/provider.ts +25 -0
- package/src/hooks/search/use-highlight-query.ts +51 -0
- package/src/hooks/sidebar.ts +63 -0
- package/src/hooks/use-async-value.ts +57 -0
- package/src/hooks/use-close-on-scroll.ts +23 -0
- package/src/hooks/use-copy-button.ts +46 -0
- package/src/hooks/use-cycle-index.ts +75 -0
- package/src/hooks/use-document-title.ts +9 -0
- package/src/hooks/use-element-size.ts +35 -0
- package/src/hooks/use-external-meta.ts +132 -0
- package/src/hooks/use-hot-key.ts +33 -0
- package/src/hooks/use-hover-follow.ts +54 -0
- package/src/hooks/use-in-view.ts +30 -0
- package/src/hooks/use-last-value.ts +15 -0
- package/src/hooks/use-marquee.ts +51 -0
- package/src/hooks/use-media-query.ts +14 -0
- package/src/hooks/use-mobile.ts +19 -0
- package/src/hooks/use-modifier-keys.ts +31 -0
- package/src/hooks/use-on-change.ts +35 -0
- package/src/hooks/use-pane-keys.ts +28 -0
- package/src/hooks/use-swipe.ts +26 -0
- package/src/hooks/use-tree.ts +102 -0
- package/src/hooks/viewer/use-in-float-bar.ts +6 -0
- package/src/hooks/viewer/use-viewer-prefs.ts +77 -0
- package/src/lib/canvas/edge.ts +173 -0
- package/src/lib/canvas/geometry.ts +53 -0
- package/src/lib/canvas/state.ts +47 -0
- package/src/lib/canvas/viewport.ts +37 -0
- package/src/lib/canvas/xyflow.ts +1 -0
- package/src/lib/config.ts +81 -0
- package/src/lib/mdx/callout.ts +20 -0
- package/src/lib/mdx/gradient.ts +15 -0
- package/src/lib/mdx/mermaid.ts +14 -0
- package/src/lib/media/crop-opaque.ts +76 -0
- package/src/lib/media/nearby-indexes.ts +6 -0
- package/src/lib/media/trim-transparent.ts +117 -0
- package/src/lib/readability/config.ts +10 -0
- package/src/lib/readability/spotlight.ts +186 -0
- package/src/lib/readability/store.ts +146 -0
- package/src/lib/tree.ts +92 -0
- package/src/lib/utils/async-cache.ts +32 -0
- package/src/lib/utils/cn.ts +1 -0
- package/src/lib/utils/format.ts +22 -0
- package/src/lib/utils/history.ts +9 -0
- package/src/lib/utils/merge-refs.ts +13 -0
- package/src/lib/utils/nav-active.ts +58 -0
- package/src/lib/utils/stored-value.ts +136 -0
- package/src/lib/utils/urls.ts +17 -0
- package/src/locales/en_us.json +119 -0
- package/src/locales/pl_pl.json +35 -0
- package/src/locales/ru_ru.json +119 -0
- package/src/locales/uk_ua.json +35 -0
- package/src/locales/zh_cn.json +17 -0
- package/src/locales/zh_tw.json +17 -0
- package/src/locales.ts +5 -0
- package/src/provider.tsx +141 -0
- package/src/types/canvas.ts +49 -0
- package/src/types/glb.ts +25 -0
- package/src/types/nav.ts +95 -0
- package/src/types/preview.ts +9 -0
- package/src/types/readability.ts +28 -0
- package/src/types/search.ts +56 -0
- package/src/types/tree.ts +18 -0
- package/src/types/viewer.ts +53 -0
- package/styles/content/base.css +194 -0
- package/styles/content/default-colors.css +51 -0
- package/styles/content/shiki.css +108 -0
- package/styles/content/typography.mjs +3941 -0
- package/styles/content.css +7 -0
- package/styles/image-zoom.css +83 -0
- package/styles/layout.css +28 -0
- package/styles/left-sidebar.css +140 -0
- package/styles/readability.css +50 -0
- package/styles/right-sidebar.css +6 -0
- package/styles/workspace.css +26 -0
- package/styles.css +413 -0
- package/README.md +0 -3
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Check, Clipboard } from 'lucide-react';
|
|
3
|
+
import {
|
|
4
|
+
type ComponentProps,
|
|
5
|
+
type CSSProperties,
|
|
6
|
+
createContext,
|
|
7
|
+
type HTMLAttributes,
|
|
8
|
+
type ReactNode,
|
|
9
|
+
type RefObject,
|
|
10
|
+
use,
|
|
11
|
+
useMemo,
|
|
12
|
+
useRef,
|
|
13
|
+
} from 'react';
|
|
14
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
15
|
+
import { useCopyButton } from '@terrafirmagreg-team/ui/hooks/use-copy-button';
|
|
16
|
+
import { buttonVariants } from '@terrafirmagreg-team/ui/components/ui/button';
|
|
17
|
+
import { useTranslations } from '@terrafirmagreg-team/translate/hooks/use-translations';
|
|
18
|
+
import { Tabs, TabsContent, TabsList, TabsTrigger } from './tabs';
|
|
19
|
+
import { mergeRefs } from '@terrafirmagreg-team/ui/lib/utils/merge-refs';
|
|
20
|
+
|
|
21
|
+
export interface CodeBlockProps extends Omit<ComponentProps<'figure'>, 'title'> {
|
|
22
|
+
title?: ReactNode;
|
|
23
|
+
|
|
24
|
+
icon?: ReactNode;
|
|
25
|
+
|
|
26
|
+
allowCopy?: boolean | 'true' | 'false';
|
|
27
|
+
|
|
28
|
+
keepBackground?: boolean;
|
|
29
|
+
|
|
30
|
+
viewportProps?: HTMLAttributes<HTMLElement>;
|
|
31
|
+
|
|
32
|
+
'data-line-numbers'?: boolean;
|
|
33
|
+
|
|
34
|
+
'data-line-numbers-start'?: number;
|
|
35
|
+
|
|
36
|
+
Actions?: (props: { className?: string; children?: ReactNode }) => ReactNode;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const TabsContext = createContext<{
|
|
40
|
+
containerRef: RefObject<HTMLDivElement | null>;
|
|
41
|
+
nested: boolean;
|
|
42
|
+
} | null>(null);
|
|
43
|
+
|
|
44
|
+
export function Pre(props: ComponentProps<'pre'>) {
|
|
45
|
+
return (
|
|
46
|
+
<pre {...props} className={cn('min-w-full w-max *:flex *:flex-col', props.className)}>
|
|
47
|
+
{props.children}
|
|
48
|
+
</pre>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function CodeBlock({
|
|
53
|
+
ref,
|
|
54
|
+
title,
|
|
55
|
+
allowCopy = true,
|
|
56
|
+
keepBackground = false,
|
|
57
|
+
icon,
|
|
58
|
+
viewportProps = {},
|
|
59
|
+
children,
|
|
60
|
+
Actions = (props) => <div {...props} className={cn('empty:hidden', props.className)} />,
|
|
61
|
+
...props
|
|
62
|
+
}: CodeBlockProps) {
|
|
63
|
+
const inTab = use(TabsContext) !== null;
|
|
64
|
+
const areaRef = useRef<HTMLDivElement>(null);
|
|
65
|
+
if (allowCopy === 'true') allowCopy = true;
|
|
66
|
+
else if (allowCopy === 'false') allowCopy = false;
|
|
67
|
+
return (
|
|
68
|
+
<figure
|
|
69
|
+
ref={ref}
|
|
70
|
+
dir="ltr"
|
|
71
|
+
{...props}
|
|
72
|
+
tabIndex={-1}
|
|
73
|
+
className={cn(
|
|
74
|
+
inTab ? 'bg-secondary -mx-px -mb-px last:rounded-b-xl' : 'my-4 bg-card rounded-xl',
|
|
75
|
+
keepBackground && 'bg-(--shiki-light-bg) dark:bg-(--shiki-dark-bg)',
|
|
76
|
+
|
|
77
|
+
'shiki relative border not-prose overflow-hidden text-sm',
|
|
78
|
+
props.className,
|
|
79
|
+
)}
|
|
80
|
+
>
|
|
81
|
+
{title ? (
|
|
82
|
+
<div className="flex text-muted-foreground items-center gap-2 h-9.5 border-b px-4">
|
|
83
|
+
{typeof icon === 'string' ? (
|
|
84
|
+
<div
|
|
85
|
+
className="[&_svg]:size-3.5"
|
|
86
|
+
dangerouslySetInnerHTML={{
|
|
87
|
+
__html: icon,
|
|
88
|
+
}}
|
|
89
|
+
/>
|
|
90
|
+
) : (
|
|
91
|
+
icon
|
|
92
|
+
)}
|
|
93
|
+
<figcaption className="flex-1 truncate">{title}</figcaption>
|
|
94
|
+
{Actions({
|
|
95
|
+
className: '-me-2',
|
|
96
|
+
children: allowCopy && <CopyButton containerRef={areaRef} />,
|
|
97
|
+
})}
|
|
98
|
+
</div>
|
|
99
|
+
) : (
|
|
100
|
+
Actions({
|
|
101
|
+
className:
|
|
102
|
+
'absolute top-2 right-2 z-2 backdrop-blur-lg rounded-lg text-muted-foreground',
|
|
103
|
+
children: allowCopy && <CopyButton containerRef={areaRef} />,
|
|
104
|
+
})
|
|
105
|
+
)}
|
|
106
|
+
<div
|
|
107
|
+
ref={areaRef}
|
|
108
|
+
{...viewportProps}
|
|
109
|
+
role="region"
|
|
110
|
+
tabIndex={0}
|
|
111
|
+
className={cn(
|
|
112
|
+
'text-[0.8125rem] py-3.5 overflow-auto max-h-[600px] scroll-container focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring',
|
|
113
|
+
viewportProps.className,
|
|
114
|
+
)}
|
|
115
|
+
style={
|
|
116
|
+
{
|
|
117
|
+
|
|
118
|
+
'--padding-right': !title ? 'calc(var(--spacing) * 8)' : undefined,
|
|
119
|
+
counterSet: props['data-line-numbers']
|
|
120
|
+
? `line ${Number(props['data-line-numbers-start'] ?? 1) - 1}`
|
|
121
|
+
: undefined,
|
|
122
|
+
...viewportProps.style,
|
|
123
|
+
} as CSSProperties
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
{children}
|
|
127
|
+
</div>
|
|
128
|
+
</figure>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function CopyButton({
|
|
133
|
+
className,
|
|
134
|
+
containerRef,
|
|
135
|
+
...props
|
|
136
|
+
}: ComponentProps<'button'> & {
|
|
137
|
+
containerRef: RefObject<HTMLElement | null>;
|
|
138
|
+
}) {
|
|
139
|
+
const t = useTranslations();
|
|
140
|
+
const { checked, onClick } = useCopyButton(() => {
|
|
141
|
+
const pre = containerRef.current?.getElementsByTagName('pre').item(0);
|
|
142
|
+
if (!pre) return;
|
|
143
|
+
|
|
144
|
+
const clone = pre.cloneNode(true) as HTMLElement;
|
|
145
|
+
clone.querySelectorAll('.copy-ignore').forEach((node) => {
|
|
146
|
+
node.replaceWith('\n');
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
return navigator.clipboard.writeText(clone.textContent ?? '');
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
return (
|
|
153
|
+
<button
|
|
154
|
+
type="button"
|
|
155
|
+
data-checked={checked || undefined}
|
|
156
|
+
className={cn(
|
|
157
|
+
buttonVariants({
|
|
158
|
+
variant: 'ghost',
|
|
159
|
+
className: 'hover:text-accent-foreground data-checked:text-accent-foreground',
|
|
160
|
+
size: 'icon-xs',
|
|
161
|
+
}),
|
|
162
|
+
className,
|
|
163
|
+
)}
|
|
164
|
+
aria-live="polite"
|
|
165
|
+
onClick={onClick}
|
|
166
|
+
{...props}
|
|
167
|
+
>
|
|
168
|
+
{checked ? <Check /> : <Clipboard />}
|
|
169
|
+
<span className="sr-only">
|
|
170
|
+
{checked
|
|
171
|
+
? t('ui.copied_text', { note: 'aria-label' })
|
|
172
|
+
: t('ui.copy_text', { note: 'aria-label' })}
|
|
173
|
+
</span>
|
|
174
|
+
</button>
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export function CodeBlockTabs({ ref, className, ...props }: ComponentProps<typeof Tabs>) {
|
|
179
|
+
const containerRef = useRef<HTMLDivElement>(null);
|
|
180
|
+
const nested = use(TabsContext) !== null;
|
|
181
|
+
|
|
182
|
+
return (
|
|
183
|
+
<Tabs
|
|
184
|
+
ref={mergeRefs(containerRef, ref)}
|
|
185
|
+
{...props}
|
|
186
|
+
className={(s) =>
|
|
187
|
+
cn(
|
|
188
|
+
'bg-card rounded-xl border',
|
|
189
|
+
!nested && 'my-4',
|
|
190
|
+
typeof className === 'function' ? className(s) : className,
|
|
191
|
+
)
|
|
192
|
+
}
|
|
193
|
+
>
|
|
194
|
+
<TabsContext
|
|
195
|
+
value={useMemo(
|
|
196
|
+
() => ({
|
|
197
|
+
containerRef,
|
|
198
|
+
nested,
|
|
199
|
+
}),
|
|
200
|
+
[nested],
|
|
201
|
+
)}
|
|
202
|
+
>
|
|
203
|
+
{props.children}
|
|
204
|
+
</TabsContext>
|
|
205
|
+
</Tabs>
|
|
206
|
+
);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
export function CodeBlockTabsList({ className, ...props }: ComponentProps<typeof TabsList>) {
|
|
210
|
+
return (
|
|
211
|
+
<TabsList
|
|
212
|
+
{...props}
|
|
213
|
+
className={(s) =>
|
|
214
|
+
cn(
|
|
215
|
+
'flex flex-row px-2 overflow-x-auto text-muted-foreground',
|
|
216
|
+
typeof className === 'function' ? className(s) : className,
|
|
217
|
+
)
|
|
218
|
+
}
|
|
219
|
+
>
|
|
220
|
+
{props.children}
|
|
221
|
+
</TabsList>
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
export function CodeBlockTabsTrigger({
|
|
226
|
+
children,
|
|
227
|
+
className,
|
|
228
|
+
...props
|
|
229
|
+
}: ComponentProps<typeof TabsTrigger>) {
|
|
230
|
+
return (
|
|
231
|
+
<TabsTrigger
|
|
232
|
+
{...props}
|
|
233
|
+
className={(s) =>
|
|
234
|
+
cn(
|
|
235
|
+
'relative group inline-flex text-sm font-medium text-nowrap items-center transition-colors gap-2 px-2 py-1.5 [&_svg]:size-3.5',
|
|
236
|
+
s.active ? 'text-primary' : 'hover:text-accent-foreground',
|
|
237
|
+
typeof className === 'function' ? className(s) : className,
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
>
|
|
241
|
+
<div className="absolute inset-x-2 bottom-0 h-px group-data-active:bg-primary" />
|
|
242
|
+
{children}
|
|
243
|
+
</TabsTrigger>
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export function CodeBlockTab(props: ComponentProps<typeof TabsContent>) {
|
|
248
|
+
return <TabsContent {...props} />;
|
|
249
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { Collapsible as Primitive } from '@base-ui/react/collapsible';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
5
|
+
|
|
6
|
+
export const Collapsible = Primitive.Root;
|
|
7
|
+
|
|
8
|
+
export const CollapsibleTrigger = Primitive.Trigger;
|
|
9
|
+
|
|
10
|
+
export function CollapsibleContent({
|
|
11
|
+
children,
|
|
12
|
+
className,
|
|
13
|
+
...props
|
|
14
|
+
}: ComponentProps<typeof Primitive.Panel>) {
|
|
15
|
+
return (
|
|
16
|
+
<Primitive.Panel
|
|
17
|
+
{...props}
|
|
18
|
+
className={(s) =>
|
|
19
|
+
cn(
|
|
20
|
+
"overflow-hidden [&[hidden]:not([hidden='until-found'])]:hidden h-(--collapsible-panel-height) transition-[height,opacity] data-starting-style:opacity-0 data-starting-style:h-0 data-ending-style:h-0 data-ending-style:opacity-0",
|
|
21
|
+
typeof className === 'function' ? className(s) : className,
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
>
|
|
25
|
+
{children}
|
|
26
|
+
</Primitive.Panel>
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export type CollapsibleProps = Primitive.Root.Props;
|
|
31
|
+
export type CollapsibleContentProps = Primitive.Panel.Props;
|
|
32
|
+
export type CollapsibleTriggerProps = Primitive.Trigger.Props;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { FileIcon, FolderIcon, FolderOpen } from 'lucide-react';
|
|
5
|
+
import { type HTMLAttributes, type ReactNode, useState } from 'react';
|
|
6
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
7
|
+
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from './collapsible';
|
|
8
|
+
|
|
9
|
+
const itemVariants = cva(
|
|
10
|
+
'flex flex-row items-center gap-2 rounded-md px-2 py-1.5 text-sm hover:bg-accent hover:text-accent-foreground [&_svg]:size-4',
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
export function Files({ className, ...props }: HTMLAttributes<HTMLDivElement>): React.ReactElement {
|
|
14
|
+
return (
|
|
15
|
+
<div className={cn('not-prose rounded-md border bg-card p-2', className)} {...props}>
|
|
16
|
+
{props.children}
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface FileProps extends HTMLAttributes<HTMLDivElement> {
|
|
22
|
+
name: string;
|
|
23
|
+
icon?: ReactNode;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface FolderProps extends HTMLAttributes<HTMLDivElement> {
|
|
27
|
+
name: string;
|
|
28
|
+
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
|
|
31
|
+
defaultOpen?: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function File({
|
|
35
|
+
name,
|
|
36
|
+
icon = <FileIcon />,
|
|
37
|
+
className,
|
|
38
|
+
...rest
|
|
39
|
+
}: FileProps): React.ReactElement {
|
|
40
|
+
return (
|
|
41
|
+
<div className={cn(itemVariants({ className }))} {...rest}>
|
|
42
|
+
{icon}
|
|
43
|
+
{name}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function Folder({ name, defaultOpen = false, ...props }: FolderProps): React.ReactElement {
|
|
49
|
+
const [open, setOpen] = useState(defaultOpen);
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<Collapsible open={open} onOpenChange={setOpen} {...props}>
|
|
53
|
+
<CollapsibleTrigger className={cn(itemVariants({ className: 'w-full' }))}>
|
|
54
|
+
{open ? <FolderOpen /> : <FolderIcon />}
|
|
55
|
+
{name}
|
|
56
|
+
</CollapsibleTrigger>
|
|
57
|
+
<CollapsibleContent>
|
|
58
|
+
<div className="ms-2 flex flex-col border-l ps-2">{props.children}</div>
|
|
59
|
+
</CollapsibleContent>
|
|
60
|
+
</Collapsible>
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { gradientImage, type GradientProps } from '@terrafirmagreg-team/ui/lib/mdx/gradient';
|
|
3
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
4
|
+
|
|
5
|
+
export function GlowHeader({
|
|
6
|
+
fade,
|
|
7
|
+
gradient,
|
|
8
|
+
from,
|
|
9
|
+
to,
|
|
10
|
+
dir,
|
|
11
|
+
image,
|
|
12
|
+
style,
|
|
13
|
+
className,
|
|
14
|
+
...props
|
|
15
|
+
}: GradientProps & { fade?: boolean; gradient?: boolean } & ComponentProps<'span'>) {
|
|
16
|
+
const boxFrom = from ?? '#fa18cf';
|
|
17
|
+
const boxTo = to ?? '#ff7967';
|
|
18
|
+
const gradientBg = gradientImage({ from, to, dir, image });
|
|
19
|
+
const boxBg = `radial-gradient(color-mix(in srgb, ${boxFrom} 18%, transparent), color-mix(in srgb, ${boxTo} 8%, transparent))`;
|
|
20
|
+
return (
|
|
21
|
+
<span
|
|
22
|
+
className={cn(
|
|
23
|
+
'mb-6 inline-block rounded-[20px] border border-transparent px-4 py-2.5 text-center',
|
|
24
|
+
className,
|
|
25
|
+
)}
|
|
26
|
+
style={{
|
|
27
|
+
backgroundImage: gradient ? `${gradientBg}, ${boxBg}` : boxBg,
|
|
28
|
+
...(gradient && {
|
|
29
|
+
WebkitBackgroundClip: 'text, border-box',
|
|
30
|
+
backgroundClip: 'text, border-box',
|
|
31
|
+
WebkitTextFillColor: 'transparent',
|
|
32
|
+
}),
|
|
33
|
+
boxShadow: `0 10px 20px color-mix(in srgb, ${boxFrom} 25%, transparent)`,
|
|
34
|
+
...(fade && { borderImage: `${gradientBg} 1` }),
|
|
35
|
+
...style,
|
|
36
|
+
}}
|
|
37
|
+
{...props}
|
|
38
|
+
/>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ComponentProps } from 'react';
|
|
2
|
+
import { gradientImage, type GradientProps } from '@terrafirmagreg-team/ui/lib/mdx/gradient';
|
|
3
|
+
import { cn } from '@terrafirmagreg-team/ui/lib/utils/cn';
|
|
4
|
+
|
|
5
|
+
export function GradientText({
|
|
6
|
+
from,
|
|
7
|
+
to,
|
|
8
|
+
dir,
|
|
9
|
+
image,
|
|
10
|
+
style,
|
|
11
|
+
className,
|
|
12
|
+
...props
|
|
13
|
+
}: GradientProps & ComponentProps<'span'>) {
|
|
14
|
+
return (
|
|
15
|
+
<span
|
|
16
|
+
className={cn('text-transparent', className)}
|
|
17
|
+
style={{
|
|
18
|
+
backgroundImage: gradientImage({ from, to, dir, image }),
|
|
19
|
+
WebkitBackgroundClip: 'text',
|
|
20
|
+
backgroundClip: 'text',
|
|
21
|
+
WebkitTextFillColor: 'transparent',
|
|
22
|
+
...style,
|
|
23
|
+
}}
|
|
24
|
+
{...props}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
}
|