Files
supabase/apps/studio/components/layouts/Navigation/NavigationBar/MobileProjectSwitcherSheetTabTrigger.tsx
Joshen Lim 607dc2bfde Chore/cleanup dead code in project branch selector (#52691)
## Context

Just some housekeeping here while going through the repo, realised that
there's dead code in `ProjectBranchSwitcher`

## Changes involved:
- `ProjectBranchSelector` is only rendered by `MobileNavigationBar`,
which `DefaultLayout` only mounts when `useBreakpoint('md')` is true.
The selector's own `isMobile` check used the same breakpoint, so its
desktop `Popover` branch could never run.

- The name `ProjectBranchSelector` is also misleading since the sheet
switches more than just the project's branch + it's mobile-only, so
opting to rename it to `MobileProjectSwitcher` instead

- Also fix org rows in the sheet being tighter than project rows.
`compactPadding` was inverted, so the embedded list got `p-0.5` on the
item and lost the default `px-2 py-1.5`

- Align buttons in `ProjectBranchSelector` across all tabs + use outline
variant for secondary action

| Previous | Updated |
|---|---|
| <img width="352" height="174" alt="image"
src="https://github.com/user-attachments/assets/24cb2985-b568-4bc1-8f53-ab3914ef0804"
/> | <img width="351" height="161" alt="image"
src="https://github.com/user-attachments/assets/e6e9b0e9-c075-4235-93ca-80c5d070c287"
/> |
| <img width="336" height="248" alt="image"
src="https://github.com/user-attachments/assets/4071b73f-f741-4598-ba01-8dc7bb6ba57a"
/> | <img width="335" height="313" alt="image"
src="https://github.com/user-attachments/assets/2bea398d-ebe9-4641-9bfe-c4a7b6b10c51"
/> |

If you meant a different table, tell me what the two columns should be.
For example, file and change, or before and after behaviour.
2026-11-04 13:33:05 +08:00

56 lines
1.7 KiB
TypeScript

import type { LucideIcon } from 'lucide-react'
import { cn, TabsTrigger } from 'ui'
export interface MobileProjectSwitcherSheetTabTriggerProps {
value: 'organization' | 'project' | 'branch'
label: string
icon: LucideIcon
isMainBranch?: boolean
isLast: boolean
}
export function MobileProjectSwitcherSheetTabTrigger({
value,
label,
icon: Icon,
isMainBranch = false,
isLast,
}: MobileProjectSwitcherSheetTabTriggerProps) {
const isBranch = value === 'branch'
const isProductionBranch = isBranch && isMainBranch
return (
<TabsTrigger
value={value}
className={cn(
'group relative text-xs flex flex-col items-center gap-1.5 px-4 py-3 data-[state=active]:bg-surface-200 data-[state=active]:border-foreground-light border-b duration-0',
isProductionBranch &&
'text-warning data-[state=active]:text-warning hover:text-warning hover:opacity-70'
)}
>
<Icon className="shrink-0" size={16} strokeWidth={1.5} />
<span className="truncate max-w-full text-xs leading-tight" title={label}>
{label}
</span>
{!isLast && (
<svg
aria-hidden="true"
width="100%"
height="100%"
viewBox="0 0 6 63"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className="absolute duration-0 bottom-0 top-0 -right-2 w-3 h-full z-10"
>
<path
d="M5.49365 31L0.493652 0V62L5.49365 31Z"
className="fill-[var(--background-dash-sidebar)] group-data-[state=active]:fill-[var(--background-surface-200)]"
/>
<path d="M0.493652 0L5.49365 31L0.493652 62" stroke="var(--border-default)" />
</svg>
)}
</TabsTrigger>
)
}