Skip to content

Commit 241f5e4

Browse files
committed
fix(web): collapse PR header actions to icons when narrow
1 parent b9b1b8f commit 241f5e4

1 file changed

Lines changed: 153 additions & 50 deletions

File tree

‎apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx‎

Lines changed: 153 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,8 +1296,8 @@ export function PullRequestDetailPanel({
12961296

12971297
return (
12981298
<div className="flex h-full min-h-0 w-full flex-col bg-background">
1299-
<div className="grid shrink-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 border-b border-border/60">
1300-
<div className="ml-4 grid h-7 min-w-0 items-center">
1299+
<div className="@container/pr-header grid min-w-0 shrink-0 grid-cols-[minmax(0,1fr)_auto] items-start gap-x-2 border-b border-border/60">
1300+
<div className="ml-4 grid h-7 min-w-0 items-center overflow-hidden">
13011301
<div
13021302
aria-hidden={condensed}
13031303
inert={condensed}
@@ -1402,7 +1402,7 @@ export function PullRequestDetailPanel({
14021402
) : null}
14031403
</div>
14041404
</div>
1405-
<div className="mr-4 flex h-7 min-w-0 flex-nowrap items-center justify-end gap-1">
1405+
<div className="mr-4 flex h-7 shrink-0 items-center justify-end gap-1">
14061406
{detail ? (
14071407
<>
14081408
{/* Checking a pull request out is the reason to open one here at all, so it is a
@@ -1415,9 +1415,17 @@ export function PullRequestDetailPanel({
14151415
<MenuTrigger
14161416
disabled={handoff !== null}
14171417
render={
1418-
<Button size="xs" variant="outline">
1418+
<Button
1419+
size="xs"
1420+
variant="outline"
1421+
aria-label={
1422+
handoff?.startsWith("checkout") ? "Checking out..." : "Check out"
1423+
}
1424+
>
14191425
<GitBranchIcon aria-hidden className="size-3.5" />
1420-
{handoff?.startsWith("checkout") ? "Checking out..." : "Check out"}
1426+
<span className="@max-[35rem]/pr-header:hidden">
1427+
{handoff?.startsWith("checkout") ? "Checking out..." : "Check out"}
1428+
</span>
14211429
<ChevronDownIcon aria-hidden className="size-3.5 text-muted-foreground" />
14221430
</Button>
14231431
}
@@ -1453,17 +1461,35 @@ export function PullRequestDetailPanel({
14531461
</Menu>
14541462
) : null}
14551463
{workflowApprovalsRequired > 0 && can("approve-workflows") ? (
1456-
<Button
1457-
size="xs"
1458-
variant="warning-outline"
1459-
disabled={actionPending}
1460-
onClick={() => setConfirmation({ open: true, action: "approve-workflows" })}
1461-
>
1462-
<PlayIcon className="size-3.5" />
1463-
{pendingAction === "approve-workflows"
1464-
? "Approving..."
1465-
: "Approve workflows to run"}
1466-
</Button>
1464+
<Tooltip>
1465+
<TooltipTrigger
1466+
render={
1467+
<Button
1468+
size="xs"
1469+
variant="warning-outline"
1470+
disabled={actionPending}
1471+
onClick={() => setConfirmation({ open: true, action: "approve-workflows" })}
1472+
aria-label={
1473+
pendingAction === "approve-workflows"
1474+
? "Approving..."
1475+
: "Approve workflows to run"
1476+
}
1477+
>
1478+
<PlayIcon aria-hidden className="size-3.5" />
1479+
<span className="@max-[40rem]/pr-header:hidden">
1480+
{pendingAction === "approve-workflows"
1481+
? "Approving..."
1482+
: "Approve workflows to run"}
1483+
</span>
1484+
</Button>
1485+
}
1486+
/>
1487+
<TooltipPopup side="top">
1488+
{pendingAction === "approve-workflows"
1489+
? "Approving..."
1490+
: "Approve workflows to run"}
1491+
</TooltipPopup>
1492+
</Tooltip>
14671493
) : null}
14681494
{/* Said where the Merge button is, because it is the answer to why nobody has
14691495
pressed it: the merge is already asked for, and the host is holding it. */}
@@ -1473,7 +1499,9 @@ export function PullRequestDetailPanel({
14731499
render={
14741500
<Badge size="control" variant="info">
14751501
<GitMergeIcon aria-hidden className="size-3.5" />
1476-
{armedAutoMergeLabel}
1502+
<span className="@max-[30rem]/pr-header:hidden">
1503+
{armedAutoMergeLabel}
1504+
</span>
14771505
</Badge>
14781506
}
14791507
/>
@@ -1483,35 +1511,85 @@ export function PullRequestDetailPanel({
14831511
</Tooltip>
14841512
) : null}
14851513
{primaryAction === "resolve" ? (
1486-
<Button
1487-
size="xs"
1488-
variant="destructive-outline"
1489-
disabled={handoff !== null}
1490-
onClick={startResolveConflicts}
1491-
>
1492-
<TriangleAlertIcon className="size-3.5" />
1493-
{handoff === "conflicts" ? "Preparing..." : "Resolve conflicts"}
1494-
</Button>
1514+
<Tooltip>
1515+
<TooltipTrigger
1516+
render={
1517+
<Button
1518+
size="xs"
1519+
variant="destructive-outline"
1520+
disabled={handoff !== null}
1521+
onClick={startResolveConflicts}
1522+
aria-label={
1523+
handoff === "conflicts" ? "Preparing..." : "Resolve conflicts"
1524+
}
1525+
>
1526+
<TriangleAlertIcon aria-hidden className="size-3.5" />
1527+
<span className="@max-[30rem]/pr-header:hidden">
1528+
{handoff === "conflicts" ? "Preparing..." : "Resolve conflicts"}
1529+
</span>
1530+
</Button>
1531+
}
1532+
/>
1533+
<TooltipPopup side="top">
1534+
{handoff === "conflicts" ? "Preparing..." : "Resolve conflicts"}
1535+
</TooltipPopup>
1536+
</Tooltip>
14951537
) : primaryAction === "ready" ? (
1496-
<Button size="xs" disabled={actionPending} onClick={() => void perform("ready")}>
1497-
Ready for review
1498-
</Button>
1538+
<Tooltip>
1539+
<TooltipTrigger
1540+
render={
1541+
<Button
1542+
size="xs"
1543+
disabled={actionPending}
1544+
onClick={() => void perform("ready")}
1545+
aria-label="Ready for review"
1546+
>
1547+
<GitPullRequestIcon
1548+
aria-hidden
1549+
className="hidden size-3.5 @max-[30rem]/pr-header:inline"
1550+
/>
1551+
<span className="@max-[30rem]/pr-header:hidden">Ready for review</span>
1552+
</Button>
1553+
}
1554+
/>
1555+
<TooltipPopup side="top">Ready for review</TooltipPopup>
1556+
</Tooltip>
14991557
) : primaryAction === "enable-auto-merge" ? (
1500-
<Button
1501-
size="xs"
1502-
disabled={actionPending}
1503-
onClick={() => setConfirmation({ open: true, action: "enable-auto-merge" })}
1504-
>
1505-
<GitMergeIcon className="size-3.5" />
1506-
{pendingAction === "enable-auto-merge" ? "Enabling..." : pendingAutoMergeLabel}
1507-
</Button>
1558+
<Tooltip>
1559+
<TooltipTrigger
1560+
render={
1561+
<Button
1562+
size="xs"
1563+
disabled={actionPending}
1564+
onClick={() => setConfirmation({ open: true, action: "enable-auto-merge" })}
1565+
aria-label={
1566+
pendingAction === "enable-auto-merge"
1567+
? "Enabling..."
1568+
: pendingAutoMergeLabel
1569+
}
1570+
>
1571+
<GitMergeIcon aria-hidden className="size-3.5" />
1572+
<span className="@max-[30rem]/pr-header:hidden">
1573+
{pendingAction === "enable-auto-merge"
1574+
? "Enabling..."
1575+
: pendingAutoMergeLabel}
1576+
</span>
1577+
</Button>
1578+
}
1579+
/>
1580+
<TooltipPopup side="top">
1581+
{pendingAction === "enable-auto-merge" ? "Enabling..." : pendingAutoMergeLabel}
1582+
</TooltipPopup>
1583+
</Tooltip>
15081584
) : primaryAction === "auto-merge-armed" ? (
15091585
<Tooltip>
15101586
<TooltipTrigger
15111587
render={
15121588
<Badge size="control" variant="info">
1513-
<GitMergeIcon className="size-3.5" />
1514-
{armedAutoMergeLabel}
1589+
<GitMergeIcon aria-hidden className="size-3.5" />
1590+
<span className="@max-[30rem]/pr-header:hidden">
1591+
{armedAutoMergeLabel}
1592+
</span>
15151593
</Badge>
15161594
}
15171595
/>
@@ -1520,13 +1598,31 @@ export function PullRequestDetailPanel({
15201598
</TooltipPopup>
15211599
</Tooltip>
15221600
) : primaryAction === "merge" ? (
1523-
<Button
1524-
size="xs"
1525-
disabled={actionPending}
1526-
onClick={() => setConfirmation({ open: true, action: "merge" })}
1527-
>
1528-
{pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel}
1529-
</Button>
1601+
<Tooltip>
1602+
<TooltipTrigger
1603+
render={
1604+
<Button
1605+
size="xs"
1606+
disabled={actionPending}
1607+
onClick={() => setConfirmation({ open: true, action: "merge" })}
1608+
aria-label={
1609+
pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel
1610+
}
1611+
>
1612+
<GitMergeIcon
1613+
aria-hidden
1614+
className="hidden size-3.5 @max-[30rem]/pr-header:inline"
1615+
/>
1616+
<span className="@max-[30rem]/pr-header:hidden">
1617+
{pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel}
1618+
</span>
1619+
</Button>
1620+
}
1621+
/>
1622+
<TooltipPopup side="top">
1623+
{pendingAction === "merge" ? "Merging..." : selectedMergeMethodLabel}
1624+
</TooltipPopup>
1625+
</Tooltip>
15301626
) : (primaryAction === "merged" || primaryAction === "closed") &&
15311627
statePresentation !== null ? (
15321628
<Badge size="control" variant="outline" className={statePresentation.toneClassName}>
@@ -1857,10 +1953,17 @@ export function PullRequestDetailPanel({
18571953
{detail ? (
18581954
<div className="col-span-2 mt-1 min-w-0 px-4 pb-4">
18591955
{titleDraft === null ? (
1860-
<div className="group flex min-w-0 items-start gap-1">
1861-
<h1 className="min-w-0 flex-1 text-base font-semibold leading-snug">
1862-
{detail.title}
1863-
</h1>
1956+
<div className="group flex min-w-0 items-center gap-1">
1957+
<Tooltip>
1958+
<TooltipTrigger
1959+
render={
1960+
<h1 className="min-w-0 flex-1 truncate text-base font-semibold leading-snug">
1961+
{detail.title}
1962+
</h1>
1963+
}
1964+
/>
1965+
<TooltipPopup side="top">{detail.title}</TooltipPopup>
1966+
</Tooltip>
18641967
{canEditPullRequestChangeRequest(detail) ? (
18651968
<Button
18661969
size="icon-xs"

0 commit comments

Comments
 (0)