Skip to content

Commit e5775a5

Browse files
authored
fix(ui): improve branch selector and display flexbox truncation (#12)
- Support custom className in BranchSelector and apply flexbox styles to its popover trigger - Replace hardcoded max-widths in GitReviewPanel with dynamic flexbox truncation
1 parent 4f8e0a0 commit e5775a5

2 files changed

Lines changed: 18 additions & 18 deletions

File tree

src/renderer/components/common/BranchSelector/BranchSelector.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ export interface BranchSelectorProps {
2828
popoverPlacement?: "top" | "bottom";
2929
forceHideLabel?: boolean;
3030
iconOnly?: boolean;
31+
className?: string;
3132
}
3233

3334
export function BranchSelector(props: BranchSelectorProps) {
@@ -161,10 +162,10 @@ export function BranchSelector(props: BranchSelectorProps) {
161162
}
162163

163164
return (
164-
<div className="flex items-center gap-1">
165+
<div className={`flex items-center gap-1 ${props.className ?? ""}`}>
165166
{worktreeMode && <span className="shrink-0 text-xs text-muted">from</span>}
166167
<Popover isOpen={isOpen} onOpenChange={setIsOpen}>
167-
<Popover.Trigger>
168+
<Popover.Trigger className="flex flex-1 min-w-0 items-center">
168169
{trigger ?? (
169170
<Tooltip delay={0}>
170171
<Button

src/renderer/views/GitReviewOverlay/parts/GitReviewPanel.tsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -152,24 +152,21 @@ export function GitReviewPanel(props: {
152152
{/* Header — full when standalone, slim git-actions-only bar when parent provides its own header */}
153153
{hideHeader ? (
154154
<div className="flex h-7 shrink-0 items-center gap-1.5 border-b border-[color:var(--border)] pl-1.5 pr-3 text-xs leading-tight">
155-
{gitStatus?.branch && (
155+
{gitStatus?.branch ? (
156156
<>
157157
{statusKey ? (
158-
<>
158+
<div className="flex min-w-0 flex-1 items-center gap-1.5">
159159
<GitBranch className="size-3 shrink-0 text-muted/50" />
160-
<div className="min-w-0">
161-
<Tooltip delay={300}>
162-
<Tooltip.Trigger tabIndex={-1} role="none">
163-
<div className="max-w-[100px] truncate text-muted">
164-
{gitStatus.branch}
165-
</div>
166-
</Tooltip.Trigger>
167-
<Tooltip.Content placement="bottom">{gitStatus.branch}</Tooltip.Content>
168-
</Tooltip>
169-
</div>
170-
</>
160+
<Tooltip delay={300}>
161+
<Tooltip.Trigger className="min-w-0 flex-1" tabIndex={-1} role="none">
162+
<span className="block truncate text-muted">{gitStatus.branch}</span>
163+
</Tooltip.Trigger>
164+
<Tooltip.Content placement="bottom">{gitStatus.branch}</Tooltip.Content>
165+
</Tooltip>
166+
</div>
171167
) : (
172168
<BranchSelector
169+
className="min-w-0 flex-1"
173170
projectId={project.id}
174171
currentBranch={gitStatus.branch}
175172
value={gitStatus.branch}
@@ -179,11 +176,11 @@ export function GitReviewPanel(props: {
179176
trigger={
180177
<button
181178
type="button"
182-
className="flex min-w-0 cursor-pointer items-center gap-1 rounded px-1.5 py-1 hover:bg-foreground/5"
179+
className="flex min-w-0 flex-1 cursor-pointer items-center gap-1 rounded px-1.5 py-1 hover:bg-foreground/5"
183180
aria-label="Switch branch"
184181
>
185182
<GitBranch className="size-3 shrink-0 text-muted/50" />
186-
<span className="max-w-[200px] truncate text-muted">
183+
<span className="block flex-1 truncate text-left text-muted">
187184
{gitStatus.branch}
188185
</span>
189186
</button>
@@ -196,8 +193,9 @@ export function GitReviewPanel(props: {
196193
</span>
197194
)}
198195
</>
196+
) : (
197+
<div className="flex-1" />
199198
)}
200-
<div className="flex-1" />
201199
{onRemove && (
202200
<button
203201
type="button"
@@ -259,6 +257,7 @@ export function GitReviewPanel(props: {
259257
</>
260258
) : (
261259
<BranchSelector
260+
className="min-w-0 flex-1"
262261
projectId={project.id}
263262
currentBranch={gitStatus.branch}
264263
value={gitStatus.branch}

0 commit comments

Comments
 (0)