ProjectBranchSelectorTrigger.tsx 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. import { ChevronsUpDown, GitBranch } from 'lucide-react'
  2. import { forwardRef } from 'react'
  3. import { cn, SidebarMenuButton } from 'ui'
  4. export interface ProjectBranchSelectorTriggerProps {
  5. displayProjectName: string
  6. selectedOrgInitial: string
  7. isBranch: boolean
  8. isProductionBranch: boolean
  9. branchDisplayName: string
  10. onGoToOrganization: () => void
  11. onClick?: () => void
  12. }
  13. export const ProjectBranchSelectorTrigger = forwardRef<
  14. HTMLButtonElement,
  15. ProjectBranchSelectorTriggerProps
  16. >(
  17. (
  18. {
  19. displayProjectName,
  20. selectedOrgInitial,
  21. isBranch,
  22. branchDisplayName,
  23. onClick,
  24. }: ProjectBranchSelectorTriggerProps,
  25. ref
  26. ) => {
  27. return (
  28. <SidebarMenuButton
  29. size="lg"
  30. 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"
  31. onClick={onClick}
  32. ref={ref}
  33. >
  34. <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">
  35. {selectedOrgInitial}
  36. </div>
  37. <div className="text-left grow min-w-0">
  38. <div className="w-full truncate text-foreground leading-tight max-w-[250px]">
  39. {displayProjectName}
  40. </div>
  41. <div
  42. className={cn(
  43. 'flex items-center gap-0.5',
  44. isBranch ? 'text-foreground-lighter' : 'text-warning'
  45. )}
  46. >
  47. <GitBranch className="shrink-0 size-3" strokeWidth={1.5} />
  48. <span className="truncate min-w-0 leading-tight text-xs">{branchDisplayName}</span>
  49. </div>
  50. </div>
  51. <ChevronsUpDown
  52. strokeWidth={1.5}
  53. className="ml-auto text-foreground-lighter w-4! h-4! md:hidden md:group-hover:flex"
  54. />
  55. </SidebarMenuButton>
  56. )
  57. }
  58. )
  59. ProjectBranchSelectorTrigger.displayName = 'ProjectBranchSelectorTrigger'