Skip to content

Commit 84dd3ef

Browse files
committed
feat(review): widen and resize the Guide chapter panel
1 parent 7c850dd commit 84dd3ef

4 files changed

Lines changed: 44 additions & 16 deletions

File tree

‎apps/web/src/components/preview/RightPanelResizeHandle.tsx‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ import { cn } from "~/lib/utils";
44
interface Props {
55
handlers: ResizableWidthHandlers;
66
className?: string;
7+
edge?: "left" | "right";
8+
label?: string;
79
}
810

9-
export function RightPanelResizeHandle({ handlers, className }: Props) {
11+
export function RightPanelResizeHandle({ handlers, className, edge = "left", label }: Props) {
1012
return (
1113
<div
1214
role="separator"
1315
aria-orientation="vertical"
16+
aria-label={label}
1417
className={cn(
15-
"group absolute inset-y-0 -left-1 z-20 w-2 cursor-col-resize select-none",
18+
"group absolute inset-y-0 z-20 w-2 cursor-col-resize select-none",
19+
edge === "left" ? "-left-1" : "-right-1",
1620
className,
1721
)}
1822
{...handlers}

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

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ import { DiffPanelLoadingState } from "../DiffPanelShell";
9292
import { DiffCommentAnnotation } from "../diffs/DiffCommentAnnotation";
9393
import { DiffFileTree } from "../diffs/DiffFileTree";
9494
import { ReviewChapterRail, ReviewChapterFileLink } from "./ReviewChapterRail";
95+
import { GuideChapterPanel } from "./guide/GuideChapterPanel";
9596
import { ReviewChapterHeader, ReviewChapterProgress } from "./ReviewChapterHeader";
9697
import { useCodeViewFileReveal } from "../diffs/useCodeViewFileReveal";
9798
import { diffFileTreeEntries } from "../diffs/diffFileTree.logic";
@@ -1832,11 +1833,7 @@ function PullRequestCodeTab({
18321833
<div className="flex h-full min-h-0 flex-col">
18331834
{toolbar}
18341835
<div className="@container/guide flex min-h-0 flex-1">
1835-
{guideFallback && guideStatus ? (
1836-
<aside className="w-80 shrink-0 overflow-y-auto border-r border-border/60 px-3 py-4 @max-[56rem]/guide:hidden">
1837-
{guideStatus}
1838-
</aside>
1839-
) : null}
1836+
{guideFallback && guideStatus ? <GuideChapterPanel>{guideStatus}</GuideChapterPanel> : null}
18401837
<div ref={scrollerRef} className="min-h-0 min-w-0 flex-1 overflow-auto">
18411838
{guideFallback && guideStatus ? (
18421839
<div className="px-4 py-3 @min-[56rem]/guide:hidden">{guideStatus}</div>
@@ -2044,13 +2041,13 @@ function PullRequestCodeTab({
20442041
</div>
20452042
) : null}
20462043
<div className="flex min-h-0 flex-1 overflow-hidden">
2047-
{chapter ? (
2048-
<aside
2049-
className={cn(
2050-
"shrink-0 overflow-y-auto border-r border-border/60 px-3 py-4 @max-[56rem]/guide:hidden",
2051-
guideFallback ? "w-80" : "w-64",
2052-
)}
2053-
>
2044+
{chapter && guideFallback ? (
2045+
<GuideChapterPanel>
2046+
{guideStatus}
2047+
{chapterRail}
2048+
</GuideChapterPanel>
2049+
) : chapter ? (
2050+
<aside className="w-64 shrink-0 overflow-y-auto border-r border-border/60 px-3 py-4 @max-[56rem]/guide:hidden">
20542051
{guideStatus}
20552052
{chapterRail}
20562053
</aside>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import type { CSSProperties, ReactNode } from "react";
2+
3+
import { useResizableWidth } from "~/hooks/useResizableWidth";
4+
5+
import { RightPanelResizeHandle } from "../../preview/RightPanelResizeHandle";
6+
7+
/** Keeps the same chapter width while a generating guide becomes a written tour. */
8+
export function GuideChapterPanel({ children }: { children: ReactNode }) {
9+
const width = useResizableWidth({
10+
storageKey: "t3code:guide-chapter-width",
11+
defaultWidth: 400,
12+
minWidth: 280,
13+
maxWidth: 640,
14+
edge: "right",
15+
});
16+
17+
return (
18+
<aside
19+
className="relative flex w-(--resizable-width) max-w-[50%] shrink-0 flex-col border-r border-border/60 @max-[56rem]/guide:hidden"
20+
style={{ "--resizable-width": `${width.width}px` } as CSSProperties}
21+
>
22+
<div className="min-h-0 flex-1 overflow-y-auto px-3 py-4">{children}</div>
23+
<RightPanelResizeHandle handlers={width.handlers} edge="right" label="Resize chapter panel" />
24+
</aside>
25+
);
26+
}

‎apps/web/src/components/pullRequest/guide/GuideTour.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { useAtomCommand } from "~/state/use-atom-command";
1313
import { isCommandPaletteOpen } from "~/commandPaletteBus";
1414

1515
import { GuideRail } from "./GuideRail";
16+
import { GuideChapterPanel } from "./GuideChapterPanel";
1617
import { GuideStop, type GuideStopHandle } from "./GuideStop";
1718
import { DiffDisplayControls } from "../../diffs/DiffDisplayControls";
1819
import type { ExcerptCommenting } from "./GuideExcerpt";
@@ -130,7 +131,7 @@ export function GuideTour({
130131
<div className="@container/guide flex h-full min-h-0 flex-col">
131132
{viewControlsTarget ? createPortal(<DiffDisplayControls />, viewControlsTarget) : null}
132133
<div className="flex min-h-0 flex-1 overflow-hidden">
133-
<aside className="w-80 shrink-0 overflow-y-auto border-r border-border/60 px-3 py-4 @max-[56rem]/guide:hidden">
134+
<GuideChapterPanel>
134135
<GuideRail
135136
files={diff.files}
136137
onSelectFile={selectFile}
@@ -147,7 +148,7 @@ export function GuideTour({
147148
}
148149
onSelect={goTo}
149150
/>
150-
</aside>
151+
</GuideChapterPanel>
151152
<main
152153
data-guide-diff-scroll
153154
ref={scrollRef}

0 commit comments

Comments
 (0)