@@ -16,6 +16,14 @@ import type {
16
16
} from '@briefer/database'
17
17
import { addComponentToDocument , decodeComponentState } from '@briefer/editor'
18
18
import ScrollBar from './ScrollBar'
19
+ import Link from 'next/link'
20
+ import allLucideIcons from '@/utils/lucideIcons'
21
+ import * as allOutlineIcons from '@heroicons/react/24/outline'
22
+
23
+ const icons : Record < string , React . ComponentType < React . ComponentProps < any > > > = {
24
+ ...allOutlineIcons ,
25
+ ...allLucideIcons ,
26
+ }
19
27
20
28
interface Props {
21
29
workspaceId : string
@@ -24,7 +32,6 @@ interface Props {
24
32
onHide : ( ) => void
25
33
yDoc ?: Y . Doc
26
34
}
27
-
28
35
export default function ReusableComponents ( props : Props ) {
29
36
const [ { data, isLoading } , api ] = useReusableComponents ( props . workspaceId )
30
37
@@ -152,6 +159,9 @@ function ReusableComponentItem(props: ReusableComponentItemProps) {
152
159
props . onRemove ( props . component )
153
160
} , [ props . onRemove , props . component ] )
154
161
162
+ const Icon =
163
+ icons [ props . component . document . icon ?? 'DocumentIcon' ] || ( ( ) => null )
164
+
155
165
return (
156
166
< div className = "px-4 py-3 font-sans block w-full" >
157
167
< div className = "flex flex-col" >
@@ -178,7 +188,13 @@ function ReusableComponentItem(props: ReusableComponentItemProps) {
178
188
< svg viewBox = "0 0 2 2" className = "h-0.5 w-0.5 fill-current" >
179
189
< circle cx = { 1 } cy = { 1 } r = { 1 } />
180
190
</ svg >
181
- { props . component . document . title || 'Untitled' }
191
+ < Link
192
+ href = { `/workspaces/${ props . workspaceId } /documents/${ props . component . document . id } ` }
193
+ className = "flex items-center gap-x-1 text-gray-400 hover:text-gray-500"
194
+ >
195
+ < Icon className = "h-3.5 w-3.5 shrink-0" aria-hidden = "true" />
196
+ { props . component . document . title || 'Untitled' }
197
+ </ Link >
182
198
</ div >
183
199
< div className = "flex items-center gap-x-2 font-medium text-gray-400 text-xs" >
184
200
Saved at{ ' ' }
0 commit comments