mirror of
https://github.com/supabase/supabase.git
synced 2026-12-04 07:29:16 +00:00
## 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.
64 lines
2.0 KiB
TypeScript
64 lines
2.0 KiB
TypeScript
import { ChevronsUpDownIcon, GitBranchIcon } from 'lucide-react'
|
|
import { forwardRef } from 'react'
|
|
import { cn, SidebarMenuButton } from 'ui'
|
|
|
|
export interface MobileProjectSwitcherTriggerProps {
|
|
displayProjectName: string
|
|
selectedOrgInitial: string
|
|
isBranch: boolean
|
|
isProductionBranch: boolean
|
|
branchDisplayName: string
|
|
onGoToOrganization: () => void
|
|
onClick?: () => void
|
|
}
|
|
|
|
export const MobileProjectSwitcherTrigger = forwardRef<
|
|
HTMLButtonElement,
|
|
MobileProjectSwitcherTriggerProps
|
|
>(
|
|
(
|
|
{
|
|
displayProjectName,
|
|
selectedOrgInitial,
|
|
isBranch,
|
|
branchDisplayName,
|
|
onClick,
|
|
}: MobileProjectSwitcherTriggerProps,
|
|
ref
|
|
) => {
|
|
return (
|
|
<SidebarMenuButton
|
|
size="lg"
|
|
className="group py-1 gap-1.5 w-full flex h-auto text-left data-open:bg-sidebar-accent data-open:text-sidebar-accent-foreground touch-manipulation gap-x-3"
|
|
onClick={onClick}
|
|
ref={ref}
|
|
>
|
|
<div className="relative flex h-8 aspect-square shrink-0 items-center bg-background-muted group-hover:border-stronger justify-center rounded-sm border border-strong text-xs">
|
|
{selectedOrgInitial}
|
|
</div>
|
|
<div className="text-left grow min-w-0">
|
|
<div className="w-full truncate text-foreground leading-tight max-w-[250px]">
|
|
{displayProjectName}
|
|
</div>
|
|
<div
|
|
className={cn(
|
|
'flex items-center gap-0.5',
|
|
isBranch ? 'text-foreground-lighter' : 'text-warning'
|
|
)}
|
|
>
|
|
<GitBranchIcon className="shrink-0 size-3" strokeWidth={1.5} />
|
|
<span className="truncate min-w-0 leading-tight text-xs">{branchDisplayName}</span>
|
|
</div>
|
|
</div>
|
|
|
|
<ChevronsUpDownIcon
|
|
strokeWidth={1.5}
|
|
className="ml-auto text-foreground-lighter w-4! h-4! md:hidden md:group-hover:flex"
|
|
/>
|
|
</SidebarMenuButton>
|
|
)
|
|
}
|
|
)
|
|
|
|
MobileProjectSwitcherTrigger.displayName = 'MobileProjectSwitcherTrigger'
|