@c-rex/templates 0.1.28 → 0.1.30
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 +61 -66
- package/src/home/layout.tsx +63 -63
- package/src/home/page.tsx +376 -376
- package/src/home/page2.tsx +383 -383
- package/src/layout.tsx +70 -70
- package/src/utils.ts +48 -48
- package/src/articles/documents/layout.tsx +0 -74
- package/src/articles/documents/page.tsx +0 -79
- package/src/articles/topics/layout.tsx +0 -70
- package/src/articles/topics/page.tsx +0 -71
- package/src/articles/wrapper.tsx +0 -216
package/src/articles/wrapper.tsx
DELETED
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import { useEffect, useRef, useState } from "react";
|
|
4
|
-
import { SidebarTrigger } from "@c-rex/ui/sidebar";
|
|
5
|
-
import { LeftSidebar } from "@c-rex/components/left-sidebar";
|
|
6
|
-
import { RightSidebar } from "@c-rex/components/right-sidebar";
|
|
7
|
-
import { Breadcrumb } from "@c-rex/components/breadcrumb";
|
|
8
|
-
import { RenderArticle } from "@c-rex/components/render-article";
|
|
9
|
-
import { articleInfoItemType, DocumentsType } from "@c-rex/types";
|
|
10
|
-
import { AvailableVersionsInterface, TreeOfContent } from "@c-rex/interfaces";
|
|
11
|
-
import { Separator } from "@c-rex/ui/separator";
|
|
12
|
-
import { ArrowBigLeft, PanelRight, ArrowBigRight, FileSearchIcon, X, Search } from "lucide-react";
|
|
13
|
-
import { SearchInput } from "../../../components/src/search-input";
|
|
14
|
-
|
|
15
|
-
import { useMultiSidebar } from "@c-rex/ui/sidebar";
|
|
16
|
-
import { Button } from "@c-rex/ui/button";
|
|
17
|
-
import { useQueryState } from "nuqs";
|
|
18
|
-
import { cn } from "@c-rex/utils";
|
|
19
|
-
import { useHighlight } from "@c-rex/contexts/highlight-provider";
|
|
20
|
-
import { useHighlightStore } from "@c-rex/components/highlight-store";
|
|
21
|
-
import { useTranslations } from "next-intl";
|
|
22
|
-
import { FavoriteButton } from "@c-rex/components/favorite-button";
|
|
23
|
-
import { RESULT_TYPES } from "@c-rex/constants";
|
|
24
|
-
import { useFavoritesStore } from "@c-rex/components/favorites-store";
|
|
25
|
-
|
|
26
|
-
type articleType = keyof typeof RESULT_TYPES;
|
|
27
|
-
|
|
28
|
-
type Props = {
|
|
29
|
-
documentLang: string,
|
|
30
|
-
articleLang: string,
|
|
31
|
-
articleAvailableVersions: AvailableVersionsInterface[],
|
|
32
|
-
documentAvailableVersions: AvailableVersionsInterface[],
|
|
33
|
-
|
|
34
|
-
htmlContent: string,
|
|
35
|
-
|
|
36
|
-
articleInfo: articleInfoItemType[],
|
|
37
|
-
documentInfo: articleInfoItemType[],
|
|
38
|
-
|
|
39
|
-
documents: DocumentsType,
|
|
40
|
-
loading: boolean
|
|
41
|
-
breadcrumbItems: TreeOfContent[],
|
|
42
|
-
treeOfContent: TreeOfContent[],
|
|
43
|
-
id: string,
|
|
44
|
-
type: articleType,
|
|
45
|
-
documentId: string
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const ArticleWrapper = ({
|
|
49
|
-
htmlContent,
|
|
50
|
-
documents,
|
|
51
|
-
documentLang,
|
|
52
|
-
articleLang,
|
|
53
|
-
articleAvailableVersions,
|
|
54
|
-
documentAvailableVersions,
|
|
55
|
-
loading,
|
|
56
|
-
treeOfContent,
|
|
57
|
-
documentInfo,
|
|
58
|
-
articleInfo,
|
|
59
|
-
breadcrumbItems,
|
|
60
|
-
id,
|
|
61
|
-
type,
|
|
62
|
-
documentId
|
|
63
|
-
}: Props) => {
|
|
64
|
-
const t = useTranslations();
|
|
65
|
-
const inputRef = useRef<HTMLInputElement>(null);
|
|
66
|
-
const { next, prev } = useHighlight();
|
|
67
|
-
const [open, setOpen] = useState(false);
|
|
68
|
-
const enableHighlight = useHighlightStore((state) => state.enable);
|
|
69
|
-
const toggleHighlight = useHighlightStore((state) => state.toggleHighlight);
|
|
70
|
-
const { rightSidebar } = useMultiSidebar()
|
|
71
|
-
const [query, setQuery] = useQueryState("q");
|
|
72
|
-
|
|
73
|
-
useEffect(() => {
|
|
74
|
-
if (open && inputRef.current) {
|
|
75
|
-
inputRef.current.focus();
|
|
76
|
-
}
|
|
77
|
-
}, [open]);
|
|
78
|
-
|
|
79
|
-
return (
|
|
80
|
-
<div className="flex w-full">
|
|
81
|
-
<LeftSidebar
|
|
82
|
-
lang={documentLang}
|
|
83
|
-
data={treeOfContent}
|
|
84
|
-
loading={loading}
|
|
85
|
-
side="left"
|
|
86
|
-
/>
|
|
87
|
-
<div className="flex-1 p-4">
|
|
88
|
-
<header className="flex h-12 gap-2 items-center justify-between">
|
|
89
|
-
<div className="flex items-center gap-2">
|
|
90
|
-
<SidebarTrigger side="left" />
|
|
91
|
-
<Separator
|
|
92
|
-
orientation="vertical"
|
|
93
|
-
className="data-[orientation=vertical]:h-4 hidden sm:block"
|
|
94
|
-
/>
|
|
95
|
-
<Breadcrumb items={breadcrumbItems} loading={loading} lang={documentLang} />
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
<SearchInput showInput={true} showPkgFilter={true} placedOn="BODY" />
|
|
99
|
-
{!loading &&
|
|
100
|
-
<div className="flex flex-row">
|
|
101
|
-
<FavoriteButton id={id} type={type} label={breadcrumbItems[breadcrumbItems.length - 1]!.label} />
|
|
102
|
-
</div>
|
|
103
|
-
}
|
|
104
|
-
</header>
|
|
105
|
-
|
|
106
|
-
<div className="pr-4 relative">
|
|
107
|
-
<RenderArticle htmlContent={htmlContent} contentLang={articleLang} />
|
|
108
|
-
|
|
109
|
-
{/*
|
|
110
|
-
<div className="absolute top-0 right-0 flex flex-col gap-2 items-end">
|
|
111
|
-
{favoritesList.map((item) => (
|
|
112
|
-
<div
|
|
113
|
-
key={item.id}
|
|
114
|
-
className={cn(
|
|
115
|
-
"group h-8 cursor-pointer w-4 hover:w-40 transition-all duration-300 relative",
|
|
116
|
-
`bg-${item.color}`,
|
|
117
|
-
item.id == id ? "rounded-r-sm" : "rounded-sm"
|
|
118
|
-
)}
|
|
119
|
-
>
|
|
120
|
-
{item.id == id && (
|
|
121
|
-
<div className={cn(
|
|
122
|
-
"absolute -left-[16px] top-1/2 -translate-y-1/2 h-8 border-t-[16px] border-t-transparent border-b-[16px] border-b-transparent border-r-[16px]",
|
|
123
|
-
`border-r-${item.color}`,
|
|
124
|
-
)} />
|
|
125
|
-
)}
|
|
126
|
-
<a
|
|
127
|
-
href={`../topics/${item.id}`}
|
|
128
|
-
className="flex items-center justify-end h-8 opacity-0 group-hover:opacity-100 text-primary-foreground transition-all duration-300 text-right px-2"
|
|
129
|
-
>
|
|
130
|
-
<span
|
|
131
|
-
className="text-right text-ellipsis overflow-hidden whitespace-nowrap"
|
|
132
|
-
title={item.label}
|
|
133
|
-
>
|
|
134
|
-
{item.label}
|
|
135
|
-
</span>
|
|
136
|
-
</a>
|
|
137
|
-
</div>
|
|
138
|
-
))}
|
|
139
|
-
</div>
|
|
140
|
-
*/}
|
|
141
|
-
</div>
|
|
142
|
-
|
|
143
|
-
<div className="w-full sm:w-auto justify-between bg-primary text-primary-foreground rounded-full shadow-lg flex sticky bottom-4 p-2 float-right gap-2 transition-all duration-300">
|
|
144
|
-
{enableHighlight && (
|
|
145
|
-
|
|
146
|
-
<>
|
|
147
|
-
<div className="flex items-center">
|
|
148
|
-
<input
|
|
149
|
-
type="text"
|
|
150
|
-
value={query as string || ""}
|
|
151
|
-
ref={inputRef}
|
|
152
|
-
onKeyDown={(e) => {
|
|
153
|
-
if (e.key === "Enter") {
|
|
154
|
-
next();
|
|
155
|
-
}
|
|
156
|
-
}}
|
|
157
|
-
|
|
158
|
-
onChange={(e) => setQuery(e.target.value || null)}
|
|
159
|
-
|
|
160
|
-
placeholder={t("search")}
|
|
161
|
-
className={cn(
|
|
162
|
-
"border border-gray-300 rounded left-12 transition-all duration-300 rounded-full h-9 bg-secondary text-secondary-foreground focus:outline-none focus:ring-2 focus:ring-blue-500",
|
|
163
|
-
open ? "w-48 opacity-100 px-2 mr-2" : "w-0 opacity-0 px-0"
|
|
164
|
-
)}
|
|
165
|
-
/>
|
|
166
|
-
|
|
167
|
-
<Button
|
|
168
|
-
variant="ghost" size="icon" rounded="full" onClick={() => setOpen(!open)}
|
|
169
|
-
>
|
|
170
|
-
{open ? <X className="w-5 h-5" /> : <Search className="w-5 h-5" />}
|
|
171
|
-
</Button>
|
|
172
|
-
|
|
173
|
-
</div>
|
|
174
|
-
|
|
175
|
-
<Button variant="ghost" size="icon" rounded="full" onClick={prev}>
|
|
176
|
-
<ArrowBigLeft />
|
|
177
|
-
</Button>
|
|
178
|
-
<Button variant="ghost" size="icon" rounded="full" onClick={next}>
|
|
179
|
-
|
|
180
|
-
<ArrowBigRight />
|
|
181
|
-
</Button>
|
|
182
|
-
</>
|
|
183
|
-
)}
|
|
184
|
-
|
|
185
|
-
<Button variant="ghost" size="icon" rounded="full" onClick={() => toggleHighlight(!enableHighlight)} className="group">
|
|
186
|
-
|
|
187
|
-
{enableHighlight ?
|
|
188
|
-
<FileSearchIcon /> :
|
|
189
|
-
<div className="relative inline-block">
|
|
190
|
-
<FileSearchIcon />
|
|
191
|
-
<span className="absolute inset-0 w-[2px] bg-primary-foreground rotate-45 translate-x-2 group-hover:bg-accent-foreground" />
|
|
192
|
-
</div>
|
|
193
|
-
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
</Button>
|
|
197
|
-
|
|
198
|
-
<Button variant="ghost" size="icon" rounded="full" onClick={rightSidebar.toggleSidebar}>
|
|
199
|
-
<PanelRight />
|
|
200
|
-
</Button>
|
|
201
|
-
|
|
202
|
-
</div>
|
|
203
|
-
</div>
|
|
204
|
-
|
|
205
|
-
<RightSidebar
|
|
206
|
-
side="right"
|
|
207
|
-
articleInfo={articleInfo}
|
|
208
|
-
documentInfo={documentInfo}
|
|
209
|
-
files={documents}
|
|
210
|
-
articleAvailableVersions={articleAvailableVersions}
|
|
211
|
-
documentAvailableVersions={documentAvailableVersions}
|
|
212
|
-
documentId={documentId}
|
|
213
|
-
/>
|
|
214
|
-
</div>
|
|
215
|
-
);
|
|
216
|
-
};
|