| ... | @@ -7,7 +7,19 @@ | ... | @@ -7,7 +7,19 @@ |
| 7 | * both themes) and the single `animate-skeleton` pulse, applied once on the container so any | 7 | * both themes) and the single `animate-skeleton` pulse, applied once on the container so any |
| 8 | * number of bars costs one opacity animation. | 8 | * number of bars costs one opacity animation. |
| 9 | */ | 9 | */ |
| | 10 | import type { PullRequestListEntry } from "@t3tools/contracts"; |
| | 11 | import { ArrowLeftIcon } from "lucide-react"; |
| | 12 | |
| 10 | import { cn } from "~/lib/utils"; | 13 | import { cn } from "~/lib/utils"; |
| | 14 | import { formatRelativeTimeLabel } from "~/timestampFormat"; |
| | 15 | |
| | 16 | import { pullRequestLabelColor } from "./pullRequestList.logic"; |
| | 17 | import { |
| | 18 | PullRequestActorLabel, |
| | 19 | PullRequestDiffStat, |
| | 20 | pullRequestChecksStatePresentation, |
| | 21 | resolvePullRequestState, |
| | 22 | } from "./pullRequestPresentation"; |
| 11 | | 23 | |
| 12 | function GhostBar({ className }: { className?: string | undefined }) { | 24 | function GhostBar({ className }: { className?: string | undefined }) { |
| 13 | return <div aria-hidden className={cn("h-3 rounded bg-muted-foreground/15", className)} />; | 25 | return <div aria-hidden className={cn("h-3 rounded bg-muted-foreground/15", className)} />; |
| ... | @@ -60,18 +72,46 @@ export function PullRequestListGhost({ | ... | @@ -60,18 +72,46 @@ export function PullRequestListGhost({ |
| 60 | * boundaries in the ghost prevents the loaded pull request from replacing one layout with | 72 | * boundaries in the ghost prevents the loaded pull request from replacing one layout with |
| 61 | * another a moment later. | 73 | * another a moment later. |
| 62 | */ | 74 | */ |
| 63 | export function PullRequestDetailGhost() { | 75 | export function PullRequestDetailGhost({ seed }: { seed?: PullRequestListEntry | null }) { |
| | 76 | const statePresentation = seed |
| | 77 | ? resolvePullRequestState({ |
| | 78 | state: seed.state, |
| | 79 | isDraft: seed.isDraft, |
| | 80 | }) |
| | 81 | : null; |
| | 82 | const checksPresentation = seed?.checksState |
| | 83 | ? pullRequestChecksStatePresentation(seed.checksState) |
| | 84 | : null; |
| | 85 | |
| 64 | return ( | 86 | return ( |
| 65 | <div | 87 | <div |
| 66 | role="status" | 88 | role="status" |
| 67 | aria-label="Loading pull request" | 89 | aria-label="Loading pull request" |
| 68 | className="motion-safe:animate-skeleton flex h-full min-h-0 flex-col overflow-hidden bg-background" | 90 | className={cn( |
| | 91 | "flex h-full min-h-0 flex-col overflow-hidden bg-background", |
| | 92 | !seed && "motion-safe:animate-skeleton", |
| | 93 | )} |
| 69 | > | 94 | > |
| 70 | <div className="shrink-0 border-b border-border/60"> | 95 | <div className="shrink-0 border-b border-border/60"> |
| 71 | <div className="flex h-7 items-center justify-between gap-3 px-4"> | 96 | <div className="flex h-7 items-center justify-between gap-3 px-4"> |
| 72 | <div className="flex min-w-0 flex-1 items-center gap-1.5"> | 97 | <div className="flex min-w-0 flex-1 items-center gap-1.5"> |
| 73 | <GhostBar className="w-24" /> | 98 | {seed && statePresentation ? ( |
| 74 | <GhostBar className="w-9" /> | 99 | <> |
| | 100 | <span className="min-w-0 truncate text-xs font-medium text-muted-foreground"> |
| | 101 | {seed.repository} |
| | 102 | </span> |
| | 103 | <span |
| | 104 | className={cn("shrink-0 text-xs font-medium", statePresentation.toneClassName)} |
| | 105 | > |
| | 106 | #{seed.number} |
| | 107 | </span> |
| | 108 | </> |
| | 109 | ) : ( |
| | 110 | <> |
| | 111 | <GhostBar className="w-24" /> |
| | 112 | <GhostBar className="w-9" /> |
| | 113 | </> |
| | 114 | )} |
| 75 | </div> | 115 | </div> |
| 76 | <div className="flex shrink-0 items-center gap-1"> | 116 | <div className="flex shrink-0 items-center gap-1"> |
| 77 | <GhostBar className="h-5 w-16 rounded-md" /> | 117 | <GhostBar className="h-5 w-16 rounded-md" /> |
| ... | @@ -80,18 +120,58 @@ export function PullRequestDetailGhost() { | ... | @@ -80,18 +120,58 @@ export function PullRequestDetailGhost() { |
| 80 | </div> | 120 | </div> |
| 81 | | 121 | |
| 82 | <div className="px-4 pb-4 pt-1"> | 122 | <div className="px-4 pb-4 pt-1"> |
| 83 | <GhostBar className="h-5 w-4/5 max-w-md" /> | 123 | {seed ? ( |
| | 124 | <h1 className="truncate text-base font-semibold leading-snug">{seed.title}</h1> |
| | 125 | ) : ( |
| | 126 | <GhostBar className="h-5 w-4/5 max-w-md" /> |
| | 127 | )} |
| 84 | <div className="mt-2 flex items-center gap-1.5"> | 128 | <div className="mt-2 flex items-center gap-1.5"> |
| 85 | <GhostBar className="size-4 rounded-full" /> | 129 | {seed ? ( |
| 86 | <GhostBar className="w-24" /> | 130 | <> |
| | 131 | <PullRequestActorLabel |
| | 132 | actor={seed.author} |
| | 133 | className="font-medium" |
| | 134 | tooltip={false} |
| | 135 | /> |
| | 136 | <span className="text-xs text-muted-foreground"> |
| | 137 | updated {formatRelativeTimeLabel(seed.updatedAt)} |
| | 138 | </span> |
| | 139 | </> |
| | 140 | ) : ( |
| | 141 | <> |
| | 142 | <GhostBar className="size-4 rounded-full" /> |
| | 143 | <GhostBar className="w-24" /> |
| | 144 | </> |
| | 145 | )} |
| 87 | </div> | 146 | </div> |
| 88 | <div className="mt-4 flex min-w-0 items-center gap-2"> | 147 | <div className="mt-4 flex min-w-0 items-center gap-2"> |
| 89 | <GhostBar className="h-6 w-24 rounded-md" /> | 148 | {seed ? ( |
| 90 | <GhostBar className="size-3 rounded-full" /> | 149 | <span className="flex min-w-0 flex-1 items-center gap-1.5 font-mono text-xs text-muted-foreground/70"> |
| 91 | <GhostBar className="h-6 w-32 rounded-md" /> | 150 | <code className="min-w-0 max-w-[40%] shrink-0 truncate">{seed.baseBranch}</code> |
| | 151 | <ArrowLeftIcon |
| | 152 | aria-label="receives changes from" |
| | 153 | className="size-3.5 shrink-0 opacity-60" |
| | 154 | /> |
| | 155 | <code className="min-w-0 flex-1 truncate">{seed.headBranch}</code> |
| | 156 | </span> |
| | 157 | ) : ( |
| | 158 | <> |
| | 159 | <GhostBar className="h-6 w-24 rounded-md" /> |
| | 160 | <GhostBar className="size-3 rounded-full" /> |
| | 161 | <GhostBar className="h-6 w-32 rounded-md" /> |
| | 162 | </> |
| | 163 | )} |
| 92 | <div className="ml-auto flex shrink-0 items-center gap-2"> | 164 | <div className="ml-auto flex shrink-0 items-center gap-2"> |
| 93 | <GhostBar className="w-10" /> | 165 | <GhostBar className="w-10" /> |
| 94 | <GhostBar className="w-20" /> | 166 | {seed ? ( |
| | 167 | <PullRequestDiffStat |
| | 168 | additions={seed.additions} |
| | 169 | deletions={seed.deletions} |
| | 170 | className="font-mono text-xs" |
| | 171 | /> |
| | 172 | ) : ( |
| | 173 | <GhostBar className="w-20" /> |
| | 174 | )} |
| 95 | </div> | 175 | </div> |
| 96 | </div> | 176 | </div> |
| 97 | </div> | 177 | </div> |
| ... | @@ -102,7 +182,19 @@ export function PullRequestDetailGhost() { | ... | @@ -102,7 +182,19 @@ export function PullRequestDetailGhost() { |
| 102 | <GhostBar className="h-6 w-16 rounded-md" /> | 182 | <GhostBar className="h-6 w-16 rounded-md" /> |
| 103 | <GhostBar className="h-6 w-12 rounded-md" /> | 183 | <GhostBar className="h-6 w-12 rounded-md" /> |
| 104 | </div> | 184 | </div> |
| 105 | <GhostBar className="w-20" /> | 185 | {checksPresentation ? ( |
| | 186 | <span |
| | 187 | className={cn( |
| | 188 | "inline-flex items-center gap-1.5 text-xs", |
| | 189 | checksPresentation.toneClassName, |
| | 190 | )} |
| | 191 | > |
| | 192 | <checksPresentation.Icon aria-hidden className="size-3.5" /> |
| | 193 | {checksPresentation.label} |
| | 194 | </span> |
| | 195 | ) : ( |
| | 196 | <GhostBar className="w-20" /> |
| | 197 | )} |
| 106 | </div> | 198 | </div> |
| 107 | </div> | 199 | </div> |
| 108 | | 200 | |
| ... | @@ -125,8 +217,29 @@ export function PullRequestDetailGhost() { | ... | @@ -125,8 +217,29 @@ export function PullRequestDetailGhost() { |
| 125 | <GhostBar className="w-10" /> | 217 | <GhostBar className="w-10" /> |
| 126 | </div> | 218 | </div> |
| 127 | <div className="flex items-center gap-1"> | 219 | <div className="flex items-center gap-1"> |
| 128 | <GhostBar className="h-5 w-24 rounded-full" /> | 220 | {seed ? ( |
| 129 | <GhostBar className="h-5 w-20 rounded-full" /> | 221 | seed.labels.slice(0, 3).map((label) => { |
| | 222 | const color = pullRequestLabelColor(label.color); |
| | 223 | return ( |
| | 224 | <span |
| | 225 | key={label.name} |
| | 226 | className="inline-flex h-5 max-w-32 items-center gap-1 truncate rounded-full border border-border/70 bg-muted/40 px-2 text-[10px] text-muted-foreground" |
| | 227 | > |
| | 228 | <span |
| | 229 | aria-hidden |
| | 230 | className="size-2 shrink-0 rounded-full bg-muted-foreground" |
| | 231 | {...(color ? { style: { backgroundColor: color } } : {})} |
| | 232 | /> |
| | 233 | <span className="truncate">{label.name}</span> |
| | 234 | </span> |
| | 235 | ); |
| | 236 | }) |
| | 237 | ) : ( |
| | 238 | <> |
| | 239 | <GhostBar className="h-5 w-24 rounded-full" /> |
| | 240 | <GhostBar className="h-5 w-20 rounded-full" /> |
| | 241 | </> |
| | 242 | )} |
| 130 | </div> | 243 | </div> |
| 131 | </div> | 244 | </div> |
| 132 | <div className="grid min-h-8 grid-cols-[6rem_minmax(0,1fr)] items-center gap-2"> | 245 | <div className="grid min-h-8 grid-cols-[6rem_minmax(0,1fr)] items-center gap-2"> |