Skip to content

Commit 5675b37

Browse files
aidenybaiamiagent
andcommitted
improve mobile: limit to 3 diagnostics, hide accordion, add bottom padding
Generated with [Ami](https://ami.dev) Co-Authored-By: Ami <noreply@ami.dev>
1 parent 3c6dd30 commit 5675b37

File tree

1 file changed

+54
-35
lines changed

1 file changed

+54
-35
lines changed

packages/website/src/components/terminal.tsx

Lines changed: 54 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const SCORE_BAR_WIDTH_MOBILE = 15;
2020
const SCORE_BAR_WIDTH_DESKTOP = 30;
2121
const SCORE_GOOD_THRESHOLD = 75;
2222
const SCORE_OK_THRESHOLD = 50;
23+
const DIAGNOSTIC_COUNT_MOBILE = 3;
2324
const TOTAL_ERROR_COUNT = 36;
2425
const AFFECTED_FILE_COUNT = 18;
2526
const ELAPSED_TIME = "2.1s";
@@ -212,35 +213,42 @@ const DiagnosticItem = ({ diagnostic }: { diagnostic: Diagnostic }) => {
212213

213214
return (
214215
<div className="mb-1">
215-
<button
216-
onClick={() => setIsOpen((previous) => !previous)}
217-
className="inline-flex items-center gap-1 text-left"
218-
>
219-
<ChevronRight
220-
size={16}
221-
className={`shrink-0 text-neutral-500 transition-transform duration-150 ${isOpen ? "rotate-90" : ""}`}
222-
/>
223-
<span>
224-
<span className="text-red-400"></span>
225-
{` ${diagnostic.message} `}
226-
<span className="text-neutral-500">({diagnostic.count})</span>
227-
</span>
228-
</button>
229-
<div
230-
className="ml-6 grid text-sm text-neutral-500 transition-[grid-template-rows,opacity] duration-200 ease-out sm:text-base"
231-
style={{
232-
gridTemplateRows: isOpen ? "1fr" : "0fr",
233-
opacity: isOpen ? 1 : 0,
234-
}}
235-
>
236-
<div className="overflow-hidden">
237-
<div className="mt-1">
238-
{diagnostic.files.map((file) => (
239-
<div key={file.path}>
240-
{file.path}
241-
{file.lines.length > 0 && `: ${file.lines.join(", ")}`}
242-
</div>
243-
))}
216+
<div className="sm:hidden">
217+
<span className="text-red-400"></span>
218+
{` ${diagnostic.message} `}
219+
<span className="text-neutral-500">({diagnostic.count})</span>
220+
</div>
221+
<div className="hidden sm:block">
222+
<button
223+
onClick={() => setIsOpen((previous) => !previous)}
224+
className="inline-flex items-center gap-1 text-left"
225+
>
226+
<ChevronRight
227+
size={16}
228+
className={`shrink-0 text-neutral-500 transition-transform duration-150 ${isOpen ? "rotate-90" : ""}`}
229+
/>
230+
<span>
231+
<span className="text-red-400"></span>
232+
{` ${diagnostic.message} `}
233+
<span className="text-neutral-500">({diagnostic.count})</span>
234+
</span>
235+
</button>
236+
<div
237+
className="ml-6 grid text-sm text-neutral-500 transition-[grid-template-rows,opacity] duration-200 ease-out sm:text-base"
238+
style={{
239+
gridTemplateRows: isOpen ? "1fr" : "0fr",
240+
opacity: isOpen ? 1 : 0,
241+
}}
242+
>
243+
<div className="overflow-hidden">
244+
<div className="mt-1">
245+
{diagnostic.files.map((file) => (
246+
<div key={file.path}>
247+
{file.path}
248+
{file.lines.length > 0 && `: ${file.lines.join(", ")}`}
249+
</div>
250+
))}
251+
</div>
244252
</div>
245253
</div>
246254
</div>
@@ -331,7 +339,7 @@ const Terminal = () => {
331339
return (
332340
<div
333341
ref={containerRef}
334-
className="h-screen w-full overflow-y-auto bg-[#0a0a0a] p-6 font-mono text-base leading-relaxed text-neutral-300 sm:p-8 sm:text-lg"
342+
className="h-screen w-full overflow-y-auto bg-[#0a0a0a] p-6 pb-32 font-mono text-base leading-relaxed text-neutral-300 sm:p-8 sm:pb-40 sm:text-lg"
335343
>
336344
<div>
337345
<span className="text-neutral-500">$ </span>
@@ -350,11 +358,22 @@ const Terminal = () => {
350358
</FadeIn>
351359
)}
352360

353-
{DIAGNOSTICS.slice(0, state.visibleDiagnosticCount).map((diagnostic) => (
354-
<FadeIn key={diagnostic.message}>
355-
<DiagnosticItem diagnostic={diagnostic} />
356-
</FadeIn>
357-
))}
361+
<div className="sm:hidden">
362+
{DIAGNOSTICS.slice(0, Math.min(state.visibleDiagnosticCount, DIAGNOSTIC_COUNT_MOBILE)).map(
363+
(diagnostic) => (
364+
<FadeIn key={diagnostic.message}>
365+
<DiagnosticItem diagnostic={diagnostic} />
366+
</FadeIn>
367+
),
368+
)}
369+
</div>
370+
<div className="hidden sm:block">
371+
{DIAGNOSTICS.slice(0, state.visibleDiagnosticCount).map((diagnostic) => (
372+
<FadeIn key={diagnostic.message}>
373+
<DiagnosticItem diagnostic={diagnostic} />
374+
</FadeIn>
375+
))}
376+
</div>
358377

359378
{state.showSeparator && <Spacer />}
360379

0 commit comments

Comments
 (0)