refactor(web): Collapsible stays a plain container (#13038)
Co-authored-by: Claude Fable 5 <[email protected]>
This commit is contained in:
1 parent
016cdb9622
commit
e420ef9833
5 files changed
+231
-235
No files matched your search
@@ -844,32 +844,33 @@ function MarkdownDetails({
|
||||
const content = childNodes.filter((_, index) => index !== summaryIndex);
|
||||
|
||||
return (
|
||||
<Collapsible
|
||||
defaultOpen={open}
|
||||
onOpenChange={setIsOpen}
|
||||
className="chat-markdown-details my-2 border-y border-border/60"
|
||||
data-markdown-details=""
|
||||
data-markdown-details-open={isOpen ? "true" : "false"}
|
||||
>
|
||||
<CollapsibleTrigger
|
||||
className="flex w-full items-center gap-2 py-2 text-left text-sm font-medium text-foreground data-panel-open:[&_svg]:rotate-90"
|
||||
data-markdown-details-summary=""
|
||||
<div className="my-2 border-y border-border/60">
|
||||
<Collapsible
|
||||
defaultOpen={open}
|
||||
onOpenChange={setIsOpen}
|
||||
data-markdown-details=""
|
||||
data-markdown-details-open={isOpen ? "true" : "false"}
|
||||
>
|
||||
<ChevronRightIcon
|
||||
className="size-4 shrink-0 text-muted-foreground transition-transform"
|
||||
aria-hidden
|
||||
/>
|
||||
<span>{summary}</span>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsiblePanel>
|
||||
<div
|
||||
className="pb-3 ps-6 text-foreground/[calc(80%+var(--appearance-contrast-boost)/5)]"
|
||||
data-markdown-details-content=""
|
||||
<CollapsibleTrigger
|
||||
className="flex w-full items-center gap-2 py-2 text-left text-sm font-medium text-foreground data-panel-open:[&_svg]:rotate-90"
|
||||
data-markdown-details-summary=""
|
||||
>
|
||||
{content}
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
<ChevronRightIcon
|
||||
className="size-4 shrink-0 text-muted-foreground transition-transform"
|
||||
aria-hidden
|
||||
/>
|
||||
<span>{summary}</span>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsiblePanel>
|
||||
<div
|
||||
className="pb-3 ps-6 text-foreground/[calc(80%+var(--appearance-contrast-boost)/5)]"
|
||||
data-markdown-details-content=""
|
||||
>
|
||||
{content}
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -350,40 +350,38 @@ function ConnectionStep({
|
||||
onToggleEnvironment={onToggleEnvironment}
|
||||
/>
|
||||
) : null}
|
||||
<Collapsible
|
||||
open={pairingOpen}
|
||||
onOpenChange={setPairingOpen}
|
||||
className="rounded-lg border border-border bg-background"
|
||||
>
|
||||
<CollapsibleTrigger
|
||||
disabled={isPairing}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="h-auto min-h-14 w-full justify-start gap-3 px-3 py-3 text-left whitespace-normal sm:h-auto"
|
||||
<div className="rounded-lg border border-border bg-background">
|
||||
<Collapsible open={pairingOpen} onOpenChange={setPairingOpen}>
|
||||
<CollapsibleTrigger
|
||||
disabled={isPairing}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="h-auto min-h-14 w-full justify-start gap-3 px-3 py-3 text-left whitespace-normal sm:h-auto"
|
||||
/>
|
||||
}
|
||||
>
|
||||
<LinkIcon className="size-4 text-muted-foreground" />
|
||||
<span className="flex-1">Add a computer</span>
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4 text-muted-foreground", pairingOpen && "rotate-90")}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<LinkIcon className="size-4 text-muted-foreground" />
|
||||
<span className="flex-1">Add a computer</span>
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4 text-muted-foreground", pairingOpen && "rotate-90")}
|
||||
/>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsiblePanel>
|
||||
<div className="px-3 pb-3">
|
||||
<PairingForm
|
||||
isPairing={isPairing}
|
||||
setIsPairing={setIsPairing}
|
||||
onPaired={(environmentId) => {
|
||||
setPairingOpen(false);
|
||||
onPaired(environmentId);
|
||||
requestAnimationFrame(() => continueRef.current?.focus());
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsiblePanel>
|
||||
<div className="px-3 pb-3">
|
||||
<PairingForm
|
||||
isPairing={isPairing}
|
||||
setIsPairing={setIsPairing}
|
||||
onPaired={(environmentId) => {
|
||||
setPairingOpen(false);
|
||||
onPaired(environmentId);
|
||||
requestAnimationFrame(() => continueRef.current?.focus());
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mt-6 flex items-center justify-end gap-3">
|
||||
<Button
|
||||
@@ -419,69 +417,67 @@ function ConnectAccountOption({
|
||||
const onDiscoveryReady = useCallback(() => setDiscoveryReady(true), []);
|
||||
|
||||
return (
|
||||
<Collapsible
|
||||
open={expanded && !!isSignedIn && discoveryReady}
|
||||
onOpenChange={setExpanded}
|
||||
className="rounded-lg border border-border bg-background"
|
||||
>
|
||||
<CollapsibleTrigger
|
||||
disabled={disabled || !isLoaded}
|
||||
onClick={(event) => {
|
||||
if (!isSignedIn) {
|
||||
event.preventDefault();
|
||||
setExpanded(true);
|
||||
openAuthPrompt();
|
||||
<div className="rounded-lg border border-border bg-background">
|
||||
<Collapsible open={expanded && !!isSignedIn && discoveryReady} onOpenChange={setExpanded}>
|
||||
<CollapsibleTrigger
|
||||
disabled={disabled || !isLoaded}
|
||||
onClick={(event) => {
|
||||
if (!isSignedIn) {
|
||||
event.preventDefault();
|
||||
setExpanded(true);
|
||||
openAuthPrompt();
|
||||
}
|
||||
}}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="h-auto min-h-14 w-full justify-start gap-3 px-3 py-3 text-left whitespace-normal sm:h-auto"
|
||||
/>
|
||||
}
|
||||
}}
|
||||
render={
|
||||
<Button
|
||||
variant="ghost"
|
||||
className="h-auto min-h-14 w-full justify-start gap-3 px-3 py-3 text-left whitespace-normal sm:h-auto"
|
||||
>
|
||||
<CloudIcon className="size-4 text-muted-foreground" />
|
||||
<span className="flex-1">T3 Connect</span>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{!isLoaded
|
||||
? "Loading sign-in…"
|
||||
: !isSignedIn
|
||||
? "Sign in"
|
||||
: !discoveryReady
|
||||
? "Loading computers…"
|
||||
: null}
|
||||
</span>
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4 text-muted-foreground", expanded && isSignedIn && "rotate-90")}
|
||||
/>
|
||||
}
|
||||
>
|
||||
<CloudIcon className="size-4 text-muted-foreground" />
|
||||
<span className="flex-1">T3 Connect</span>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
{!isLoaded
|
||||
? "Loading sign-in…"
|
||||
: !isSignedIn
|
||||
? "Sign in"
|
||||
: !discoveryReady
|
||||
? "Loading computers…"
|
||||
: null}
|
||||
</span>
|
||||
<ChevronRightIcon
|
||||
className={cn("size-4 text-muted-foreground", expanded && isSignedIn && "rotate-90")}
|
||||
/>
|
||||
</CollapsibleTrigger>
|
||||
<CollapsiblePanel keepMounted>
|
||||
<div className="px-3 pb-3">
|
||||
<div className="mb-3 space-y-1.5">
|
||||
{isSignedIn ? (
|
||||
<CloudEnvironmentConnectRows
|
||||
primaryEnvironmentId={null}
|
||||
savedEnvironments={environments}
|
||||
showSavedEnvironments
|
||||
onDiscoveryReady={onDiscoveryReady}
|
||||
selection={{ selectedIds, onChange: onToggleEnvironment, autoSelectedComputers }}
|
||||
refreshWhileEmpty
|
||||
empty={
|
||||
<p className="py-3 text-sm text-muted-foreground">No computers linked yet.</p>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</CollapsibleTrigger>
|
||||
<CollapsiblePanel keepMounted>
|
||||
<div className="px-3 pb-3">
|
||||
<div className="mb-3 space-y-1.5">
|
||||
{isSignedIn ? (
|
||||
<CloudEnvironmentConnectRows
|
||||
primaryEnvironmentId={null}
|
||||
savedEnvironments={environments}
|
||||
showSavedEnvironments
|
||||
onDiscoveryReady={onDiscoveryReady}
|
||||
selection={{ selectedIds, onChange: onToggleEnvironment, autoSelectedComputers }}
|
||||
refreshWhileEmpty
|
||||
empty={
|
||||
<p className="py-3 text-sm text-muted-foreground">No computers linked yet.</p>
|
||||
}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Run this on each computer you want to connect.
|
||||
</p>
|
||||
<CommandBlock command="npx t3 connect" className="mt-3" />
|
||||
<p className="mt-3 text-xs text-muted-foreground">
|
||||
Keep T3 Code running. Select the computers you want to set up above.
|
||||
</p>
|
||||
</div>
|
||||
<p className="text-sm text-muted-foreground">
|
||||
Run this on each computer you want to connect.
|
||||
</p>
|
||||
<CommandBlock command="npx t3 connect" className="mt-3" />
|
||||
<p className="mt-3 text-xs text-muted-foreground">
|
||||
Keep T3 Code running. Select the computers you want to set up above.
|
||||
</p>
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -1406,63 +1406,63 @@ function PullRequestCodeTab({
|
||||
{/* Above the code, closed, and counted: these belong to the change rather than to any
|
||||
line of it, and in the stream they read as cards dropped into the patch. */}
|
||||
{orphanFiles.size > 0 ? (
|
||||
<Collapsible
|
||||
className="shrink-0 border-b border-border/60"
|
||||
open={orphansOpen}
|
||||
onOpenChange={setOrphansOpen}
|
||||
>
|
||||
{/* Still a heading, so the section keeps its place in a screen reader's outline;
|
||||
<div className="shrink-0 border-b border-border/60">
|
||||
<Collapsible open={orphansOpen} onOpenChange={setOrphansOpen}>
|
||||
{/* Still a heading, so the section keeps its place in a screen reader's outline;
|
||||
the count is spelled out there rather than left as a bare number. */}
|
||||
<h2>
|
||||
<CollapsibleTrigger className="flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground">
|
||||
{/* While slices are still arriving a conversation may simply belong to a file
|
||||
<h2>
|
||||
<CollapsibleTrigger className="flex w-full items-center gap-1.5 px-4 py-2 text-left text-xs text-muted-foreground">
|
||||
{/* While slices are still arriving a conversation may simply belong to a file
|
||||
that has not landed yet, which is not the same as being off the diff. */}
|
||||
<span>
|
||||
{nextCursor === null
|
||||
? "Conversations not on the current diff"
|
||||
: "Conversations not on the diff loaded so far"}
|
||||
</span>
|
||||
<ChevronRightIcon
|
||||
aria-hidden
|
||||
className={cn("size-3.5 transition-transform", orphansOpen && "rotate-90")}
|
||||
/>
|
||||
<span aria-hidden className="tabular-nums">
|
||||
{orphanThreads.length}
|
||||
</span>
|
||||
<span className="sr-only">
|
||||
{orphanThreads.length === 1
|
||||
? "1 conversation"
|
||||
: `${orphanThreads.length} conversations`}
|
||||
</span>
|
||||
</CollapsibleTrigger>
|
||||
</h2>
|
||||
<CollapsiblePanel>
|
||||
{/* Capped: opened on a change with dozens of them, this would otherwise leave no
|
||||
<span>
|
||||
{nextCursor === null
|
||||
? "Conversations not on the current diff"
|
||||
: "Conversations not on the diff loaded so far"}
|
||||
</span>
|
||||
<ChevronRightIcon
|
||||
aria-hidden
|
||||
className={cn("size-3.5 transition-transform", orphansOpen && "rotate-90")}
|
||||
/>
|
||||
<span aria-hidden className="tabular-nums">
|
||||
{orphanThreads.length}
|
||||
</span>
|
||||
<span className="sr-only">
|
||||
{orphanThreads.length === 1
|
||||
? "1 conversation"
|
||||
: `${orphanThreads.length} conversations`}
|
||||
</span>
|
||||
</CollapsibleTrigger>
|
||||
</h2>
|
||||
<CollapsiblePanel>
|
||||
{/* Capped: opened on a change with dozens of them, this would otherwise leave no
|
||||
room for the diff it sits above. */}
|
||||
<div className="max-h-64 space-y-3 overflow-auto px-4 pb-3">
|
||||
{[...orphanFiles].map(([path, threads]) => (
|
||||
<div key={path}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={<p className="truncate px-3 text-xs text-muted-foreground">{path}</p>}
|
||||
/>
|
||||
<TooltipPopup side="top">{path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<div className="mt-1 space-y-2">
|
||||
{threads.map((thread) => (
|
||||
<div key={thread.id}>
|
||||
{thread.line === null ? null : (
|
||||
<p className="px-3 text-xs text-muted-foreground">Line {thread.line}</p>
|
||||
)}
|
||||
{renderThreadCard(thread)}
|
||||
</div>
|
||||
))}
|
||||
<div className="max-h-64 space-y-3 overflow-auto px-4 pb-3">
|
||||
{[...orphanFiles].map(([path, threads]) => (
|
||||
<div key={path}>
|
||||
<Tooltip>
|
||||
<TooltipTrigger
|
||||
render={
|
||||
<p className="truncate px-3 text-xs text-muted-foreground">{path}</p>
|
||||
}
|
||||
/>
|
||||
<TooltipPopup side="top">{path}</TooltipPopup>
|
||||
</Tooltip>
|
||||
<div className="mt-1 space-y-2">
|
||||
{threads.map((thread) => (
|
||||
<div key={thread.id}>
|
||||
{thread.line === null ? null : (
|
||||
<p className="px-3 text-xs text-muted-foreground">Line {thread.line}</p>
|
||||
)}
|
||||
{renderThreadCard(thread)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
))}
|
||||
</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="flex min-h-0 flex-1 overflow-hidden">
|
||||
{/* Relative wrapper so the review overlay floats over the diff rather than pushing it
|
||||
|
||||
@@ -378,74 +378,73 @@ function CommentGroup({
|
||||
null,
|
||||
);
|
||||
return (
|
||||
<Collapsible
|
||||
className="overflow-hidden rounded-lg border border-border/70 bg-muted/20"
|
||||
onOpenChange={onOpenChange}
|
||||
>
|
||||
<div className="flex items-center gap-3 pl-3">
|
||||
<div className="flex shrink-0 -space-x-1.5">
|
||||
{authors.slice(0, 3).map((actor) => (
|
||||
<PullRequestActorLabel
|
||||
key={actor?.login ?? "ghost"}
|
||||
actor={actor}
|
||||
profileUrl={
|
||||
detail.provider === "github" && actor
|
||||
? new URL(
|
||||
actor.isBot || actor.login.endsWith("[bot]")
|
||||
? `/apps/${encodeURIComponent(actor.login.replace(/\[bot\]$/, ""))}`
|
||||
: `/${encodeURIComponent(actor.login)}`,
|
||||
detail.url,
|
||||
).toString()
|
||||
: null
|
||||
}
|
||||
labelClassName="sr-only"
|
||||
className="relative rounded-full bg-background ring-2 ring-background hover:z-10 focus-visible:z-10 [&>img]:size-6 [&>span:first-child]:size-6"
|
||||
/>
|
||||
))}
|
||||
{authors.length > 3 ? (
|
||||
<span className="relative flex size-6 items-center justify-center rounded-full bg-muted text-[10px] text-muted-foreground ring-2 ring-background">
|
||||
+{authors.length - 3}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<CollapsibleTrigger
|
||||
aria-label={label}
|
||||
className="group flex min-w-0 flex-1 items-center gap-3 rounded-md py-3 pr-3 text-left hover:bg-muted/30"
|
||||
>
|
||||
<span className="min-w-0 flex-1 space-y-1">
|
||||
<span className="block text-xs font-medium text-foreground/90">{label}</span>
|
||||
<span className="flex flex-wrap gap-x-1.5 text-[11px] text-muted-foreground">
|
||||
<span>
|
||||
{authors.length} {authors.length === 1 ? "author" : "authors"}
|
||||
<div className="overflow-hidden rounded-lg border border-border bg-background">
|
||||
<Collapsible onOpenChange={onOpenChange}>
|
||||
<div className="flex items-center gap-3 pl-3">
|
||||
<div className="flex shrink-0 -space-x-1.5">
|
||||
{authors.slice(0, 3).map((actor) => (
|
||||
<PullRequestActorLabel
|
||||
key={actor?.login ?? "ghost"}
|
||||
actor={actor}
|
||||
profileUrl={
|
||||
detail.provider === "github" && actor
|
||||
? new URL(
|
||||
actor.isBot || actor.login.endsWith("[bot]")
|
||||
? `/apps/${encodeURIComponent(actor.login.replace(/\[bot\]$/, ""))}`
|
||||
: `/${encodeURIComponent(actor.login)}`,
|
||||
detail.url,
|
||||
).toString()
|
||||
: null
|
||||
}
|
||||
labelClassName="sr-only"
|
||||
className="relative rounded-full bg-background ring-2 ring-background hover:z-10 focus-visible:z-10 [&>img]:size-6 [&>span:first-child]:size-6"
|
||||
/>
|
||||
))}
|
||||
{authors.length > 3 ? (
|
||||
<span className="relative flex size-6 items-center justify-center rounded-full bg-muted text-[10px] text-muted-foreground ring-2 ring-background">
|
||||
+{authors.length - 3}
|
||||
</span>
|
||||
{fileCount > 0 ? (
|
||||
) : null}
|
||||
</div>
|
||||
<CollapsibleTrigger
|
||||
aria-label={label}
|
||||
className="group flex min-w-0 flex-1 items-center gap-3 rounded-md py-3 pr-3 text-left hover:bg-muted/30"
|
||||
>
|
||||
<span className="min-w-0 flex-1 space-y-1">
|
||||
<span className="block text-xs font-medium text-foreground/90">{label}</span>
|
||||
<span className="flex flex-wrap gap-x-1.5 text-[11px] text-muted-foreground">
|
||||
<span>
|
||||
· {fileCount} {fileCount === 1 ? "file" : "files"}
|
||||
{authors.length} {authors.length === 1 ? "author" : "authors"}
|
||||
</span>
|
||||
) : null}
|
||||
{latest ? (
|
||||
<span>
|
||||
· Latest{" "}
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<time dateTime={latest} />}>
|
||||
{formatRelativeTimeLabel(latest)}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup>{new Date(latest).toLocaleString()}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</span>
|
||||
) : null}
|
||||
{fileCount > 0 ? (
|
||||
<span>
|
||||
· {fileCount} {fileCount === 1 ? "file" : "files"}
|
||||
</span>
|
||||
) : null}
|
||||
{latest ? (
|
||||
<span>
|
||||
· Latest{" "}
|
||||
<Tooltip>
|
||||
<TooltipTrigger render={<time dateTime={latest} />}>
|
||||
{formatRelativeTimeLabel(latest)}
|
||||
</TooltipTrigger>
|
||||
<TooltipPopup>{new Date(latest).toLocaleString()}</TooltipPopup>
|
||||
</Tooltip>
|
||||
</span>
|
||||
) : null}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<ChevronRightIcon
|
||||
aria-hidden
|
||||
className="size-3.5 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-90"
|
||||
/>
|
||||
</CollapsibleTrigger>
|
||||
</div>
|
||||
<CollapsiblePanel keepMounted>
|
||||
<div className="border-t border-border/60 px-3 pb-3">{children}</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
<ChevronRightIcon
|
||||
aria-hidden
|
||||
className="size-3.5 shrink-0 text-muted-foreground transition-transform group-data-panel-open:rotate-90"
|
||||
/>
|
||||
</CollapsibleTrigger>
|
||||
</div>
|
||||
<CollapsiblePanel keepMounted>
|
||||
<div className="border-t border-border/60 px-3 pb-3">{children}</div>
|
||||
</CollapsiblePanel>
|
||||
</Collapsible>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ import * as NodeURL from "node:url";
|
||||
// components/ui exports are migrated to variants (see vite.config.ts). This gate keeps the
|
||||
// count from growing: CI fails when findings exceed the ceiling. Lower the ceiling when you
|
||||
// migrate a file, and delete this script when the rule becomes an error.
|
||||
export const RESTYLE_CEILING = 793;
|
||||
export const RESTYLE_CEILING = 776;
|
||||
|
||||
const RULE = "shadcn(no-restyle)";
|
||||
|
||||
|
||||
Reference in new issue
Block a user