@infinilabs/doc-detail 0.0.0 → 0.0.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.
@@ -1,12 +1,30 @@
1
- import { Button, Card, Typography } from "antd";
2
- import { SquareArrowOutUpRight } from "lucide-react";
3
- import type { FC, HTMLAttributes } from "react";
1
+ import { Typography } from "antd";
2
+ import {
3
+ ChevronRight,
4
+ Dot,
5
+ Ellipsis,
6
+ Minus,
7
+ SquareArrowOutUpRight,
8
+ } from "lucide-react";
9
+ import { motion } from "motion/react";
10
+
11
+ import { useState, type FC, type HTMLAttributes, type ReactNode } from "react";
4
12
  import Preview from "./components/Preview";
5
13
  import AIInterpretation from "./components/AIInterpretation";
6
14
  import { cn } from "@/utils/cn";
15
+ import ActionButton from "../ActionButton";
7
16
 
8
17
  const { Text } = Typography;
9
18
 
19
+ export type MetadataContentType =
20
+ | "image"
21
+ | "video"
22
+ | "markdown"
23
+ | "pdf"
24
+ | "docx"
25
+ | "pptx"
26
+ | "xlsx";
27
+
10
28
  export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
11
29
  data: {
12
30
  source: {
@@ -55,6 +73,10 @@ export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
55
73
  width: number;
56
74
  height: number;
57
75
  };
76
+ content_type: MetadataContentType;
77
+ mime_type: string;
78
+ preview_url: string;
79
+ ai_insights: string;
58
80
  };
59
81
  last_updated_by: {
60
82
  user: {
@@ -79,12 +101,15 @@ export interface DocDetailProps extends HTMLAttributes<HTMLDivElement> {
79
101
  size?: string;
80
102
  };
81
103
  };
104
+ extraButtons?: ReactNode[];
82
105
  }
83
106
 
84
107
  const DocDetail: FC<DocDetailProps> = (props) => {
85
- const { data, i18n, className, ...rest } = props;
108
+ const { data, i18n, extraButtons, className, ...rest } = props;
109
+
110
+ const [visibleMore, setVisibleMore] = useState(false);
86
111
 
87
- const extraInfo = [
112
+ const moreInfo = [
88
113
  {
89
114
  label: i18n?.labels?.updatedAt ?? "Updated At",
90
115
  value: data?.last_updated_by?.timestamp,
@@ -108,68 +133,85 @@ const DocDetail: FC<DocDetailProps> = (props) => {
108
133
  ];
109
134
 
110
135
  return (
111
- <div className={cn("flex flex-col h-full", className)} {...rest}>
112
- <div className="flex flex-col flex-1 mb-6 overflow-hidden">
113
- <div>
114
- <img src={data?.icon} className="size-6 mr-3 float-left" />
136
+ <div
137
+ className={cn("flex flex-col h-full overflow-hidden", className)}
138
+ {...rest}
139
+ >
140
+ <div>
141
+ <img src={data?.icon} className="size-6 mr-3 float-left" />
115
142
 
116
- <div className="text-4.5/6 text-primary">{data?.title}</div>
117
- </div>
143
+ <div className="text-4.5/6 text-primary">{data?.title}</div>
144
+ </div>
118
145
 
119
- <Text type="secondary" className="block my-3 text-3">
146
+ <div className="flex items-center justify-between my-2">
147
+ <Text
148
+ type="secondary"
149
+ className="inline-flex items-center gap-0.5 text-3"
150
+ >
120
151
  <span>{data?.source?.name}</span>
121
- <span> &gt; </span>
152
+ <ChevronRight className="size-3" />
122
153
  <span>{data?.category}</span>
123
- <span> | </span>
154
+ <Minus className="size-3 rotate-90" />
124
155
  <span>{data?.owner?.username}</span>
125
- <span> · </span>
156
+ <Dot className="size-3" />
126
157
  <span>{data?.last_updated_by?.timestamp}</span>
158
+
159
+ <Ellipsis
160
+ className="pl-2 size-3 hover:text-primary transition cursor-pointer"
161
+ onClick={() => {
162
+ setVisibleMore((prev) => !prev);
163
+ }}
164
+ />
127
165
  </Text>
128
166
 
129
- <div className="flex gap-2 mb-6">
130
- <Button
131
- color="primary"
132
- variant="filled"
133
- shape="round"
134
- icon={<SquareArrowOutUpRight className="size-4" />}
167
+ <div className="inline-flex gap-2">
168
+ {extraButtons}
169
+
170
+ <ActionButton
171
+ icon={<SquareArrowOutUpRight />}
135
172
  onClick={() => {
136
173
  window.open(data.url);
137
174
  }}
138
175
  >
139
176
  {i18n?.buttons?.openSource ?? "Open Source"}
140
- </Button>
141
- </div>
142
-
143
- <div className="flex flex-col gap-6 flex-1 overflow-auto">
144
- <Preview {...props} />
145
-
146
- <AIInterpretation {...props} />
177
+ </ActionButton>
147
178
  </div>
148
179
  </div>
149
180
 
150
- <Card
151
- classNames={{
152
- root: "border-border",
153
- body: "flex flex-wrap gap-row-2 py-4!",
181
+ <motion.div
182
+ className="bg-black/3 dark:bg-white/4 rounded-lg overflow-hidden"
183
+ initial={false}
184
+ animate={{
185
+ height: visibleMore ? "auto" : 0,
186
+ opacity: visibleMore ? 1 : 0,
187
+ marginBottom: visibleMore ? "1rem" : 0,
154
188
  }}
155
189
  >
156
- {extraInfo.map((item) => {
157
- const { label, value } = item;
158
-
159
- return (
160
- <div
161
- key={label}
162
- className="w-1/2 inline-flex items-center <sm:w-full"
163
- >
164
- <Text type="secondary" className="w-24">
165
- {label}
166
- </Text>
167
-
168
- <span>{value ?? "-"}</span>
169
- </div>
170
- );
171
- })}
172
- </Card>
190
+ <div className="flex flex-wrap gap-row-2 p-4">
191
+ {moreInfo.map((item) => {
192
+ const { label, value } = item;
193
+
194
+ return (
195
+ <div
196
+ key={label}
197
+ className="w-1/2 inline-flex items-center <sm:w-full"
198
+ >
199
+ <Text type="secondary" className="w-24">
200
+ {label}
201
+ </Text>
202
+
203
+ <span className="text-3.5">{value ?? "-"}</span>
204
+ </div>
205
+ );
206
+ })}
207
+ </div>
208
+ </motion.div>
209
+
210
+ <div className="flex flex-col gap-4 flex-1 overflow-auto">
211
+ <Preview {...props} />
212
+
213
+ <AIInterpretation {...props} />
214
+ </div>
173
215
  </div>
174
216
  );
175
217
  };
@@ -1,4 +1,5 @@
1
1
  import "virtual:uno.css";
2
2
  import DocDetail from "./DocDetail";
3
+ import ActionButton from "./ActionButton";
3
4
 
4
- export { DocDetail };
5
+ export { DocDetail, ActionButton };