Skip to content

Commit 351d00b

Browse files
committed
feat: improve layout responsiveness of operation viewer
1 parent a00c360 commit 351d00b

File tree

2 files changed

+35
-40
lines changed

2 files changed

+35
-40
lines changed

src/components/drawer/DrawerLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const DrawerLayout: FCC<{
55
}> = ({ title, children }) => {
66
return (
77
<section className="flex flex-col relative h-full">
8-
<div className="px-8 py-2 text-lg font-medium flex items-center bg-slate-100 shadow w-full h-12 dark:bg-slate-900 dark:text-white">
8+
<div className="px-4 md:px-8 py-2 text-lg font-medium flex flex-wrap items-center bg-slate-100 shadow w-full min-h-12 dark:bg-slate-900 dark:text-white">
99
{title}
1010
</div>
1111

src/components/viewer/OperationViewer.tsx

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -189,38 +189,33 @@ export const OperationViewer: ComponentType<{
189189

190190
<div className="flex-1" />
191191

192-
{operation.uploaderId === auth.userId && (
193-
<Popover2
194-
content={
195-
<ManageMenu
196-
operation={operation}
197-
onUpdate={() => onCloseDrawer()}
198-
/>
199-
}
200-
>
201-
<Button
202-
className="ml-4"
203-
icon="wrench"
204-
text="管理"
205-
rightIcon="caret-down"
206-
/>
207-
</Popover2>
208-
)}
209-
210-
<Button
211-
className="ml-4"
212-
icon="download"
213-
text="下载原 JSON"
214-
onClick={() => handleDownloadJSON(operation.parsedContent)}
215-
/>
192+
<div className="flex flex-wrap items-center gap-2 md:gap-4">
193+
{operation.uploaderId === auth.userId && (
194+
<Popover2
195+
content={
196+
<ManageMenu
197+
operation={operation}
198+
onUpdate={() => onCloseDrawer()}
199+
/>
200+
}
201+
>
202+
<Button icon="wrench" text="管理" rightIcon="caret-down" />
203+
</Popover2>
204+
)}
205+
206+
<Button
207+
icon="download"
208+
text="下载原 JSON"
209+
onClick={() => handleDownloadJSON(operation.parsedContent)}
210+
/>
216211

217-
<Button
218-
className="ml-4"
219-
icon="clipboard"
220-
text="复制神秘代码"
221-
intent="primary"
222-
onClick={() => copyShortCode(operation)}
223-
/>
212+
<Button
213+
icon="clipboard"
214+
text="复制神秘代码"
215+
intent="primary"
216+
onClick={() => copyShortCode(operation)}
217+
/>
218+
</div>
224219
</>
225220
}
226221
>
@@ -276,10 +271,10 @@ function OperationViewerInner({
276271
handleRating: (decision: OpRatingType) => Promise<void>
277272
}) {
278273
return (
279-
<div className="h-full overflow-auto py-4 px-8 pt-8">
274+
<div className="h-full overflow-auto p-4 md:p-8">
280275
<H3>{operation.parsedContent.doc.title}</H3>
281276

282-
<div className="grid grid-rows-1 grid-cols-3 gap-8">
277+
<div className="flex flex-col-reverse md:grid grid-rows-1 grid-cols-3 gap-2 md:gap-8">
283278
<div className="flex flex-col">
284279
<Paragraphs content={operation.parsedContent.doc.details} linkify />
285280
</div>
@@ -330,20 +325,20 @@ function OperationViewerInner({
330325
</FactItem>
331326
</div>
332327

333-
<div className="flex flex-col items-start select-none tabular-nums">
334-
<FactItem title="浏览量" icon="eye-open">
328+
<div className="flex flex-wrap md:flex-col items-start select-none tabular-nums gap-4">
329+
<FactItem dense title="浏览量" icon="eye-open">
335330
<span className="text-gray-800 dark:text-slate-100 font-bold">
336331
{operation.views}
337332
</span>
338333
</FactItem>
339334

340-
<FactItem title="发布于" icon="time">
335+
<FactItem dense title="发布于" icon="time">
341336
<span className="text-gray-800 dark:text-slate-100 font-bold">
342337
<RelativeTime moment={operation.uploadTime} />
343338
</span>
344339
</FactItem>
345340

346-
<FactItem title="作者" icon="user">
341+
<FactItem dense title="作者" icon="user">
347342
<UserName
348343
className="text-gray-800 dark:text-slate-100 font-bold"
349344
userId={operation.uploaderId}
@@ -409,7 +404,7 @@ function OperationViewerInnerDetails({ operation }: { operation: Operation }) {
409404
/>
410405
</H4>
411406
<Collapse isOpen={showOperators}>
412-
<div className="mt-2 flex flex-wrap -ml-4">
407+
<div className="mt-2 flex flex-wrap -ml-4 gap-y-2">
413408
{!operation.parsedContent.opers?.length &&
414409
!operation.parsedContent.groups?.length && (
415410
<NonIdealState
@@ -432,7 +427,7 @@ function OperationViewerInnerDetails({ operation }: { operation: Operation }) {
432427
key={group.name}
433428
>
434429
<H6 className="text-gray-800">{group.name}</H6>
435-
<div className="flex gap-1">
430+
<div className="flex flex-wrap gap-y-2">
436431
{group.opers
437432
?.filter(Boolean)
438433
.map((operator) => (

0 commit comments

Comments
 (0)