Home / File/ team-switcher.tsx — ui Source File

team-switcher.tsx — ui Source File

Architecture documentation for team-switcher.tsx, a tsx file in the ui codebase. 4 imports, 0 dependents.

File tsx ComponentRegistry UIPrimitives 4 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  d86a1d63_189f_b85e_f6a3_b77c1ae02a01["team-switcher.tsx"]
  1d141819_425e_b5fd_4c8e_32f7c6a42cf2["react"]
  d86a1d63_189f_b85e_f6a3_b77c1ae02a01 --> 1d141819_425e_b5fd_4c8e_32f7c6a42cf2
  ac307fe4_34c0_4667_089c_c9e7c15ca708["dropdown-menu"]
  d86a1d63_189f_b85e_f6a3_b77c1ae02a01 --> ac307fe4_34c0_4667_089c_c9e7c15ca708
  f1a5091e_9f4f_a457_6394_4e05eb42bbf1["sidebar"]
  d86a1d63_189f_b85e_f6a3_b77c1ae02a01 --> f1a5091e_9f4f_a457_6394_4e05eb42bbf1
  de6fac54_74ca_6c25_8f8b_d1ba3287dbf2["icon-placeholder"]
  d86a1d63_189f_b85e_f6a3_b77c1ae02a01 --> de6fac54_74ca_6c25_8f8b_d1ba3287dbf2
  style d86a1d63_189f_b85e_f6a3_b77c1ae02a01 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

"use client"

import * as React from "react"

import {
  DropdownMenu,
  DropdownMenuContent,
  DropdownMenuGroup,
  DropdownMenuItem,
  DropdownMenuLabel,
  DropdownMenuSeparator,
  DropdownMenuShortcut,
  DropdownMenuTrigger,
} from "@/registry/bases/base/ui/dropdown-menu"
import {
  SidebarMenu,
  SidebarMenuButton,
  SidebarMenuItem,
  useSidebar,
} from "@/registry/bases/base/ui/sidebar"
import { IconPlaceholder } from "@/app/(create)/components/icon-placeholder"

export function TeamSwitcher({
  teams,
}: {
  teams: {
    name: string
    logo: React.ReactNode
    plan: string
  }[]
}) {
  const { isMobile } = useSidebar()
  const [activeTeam, setActiveTeam] = React.useState(teams[0])
  if (!activeTeam) {
    return null
  }
  return (
    <SidebarMenu>
      <SidebarMenuItem>
        <DropdownMenu>
          <DropdownMenuTrigger
            render={
              <SidebarMenuButton
                size="lg"
                className="data-open:bg-sidebar-accent data-open:text-sidebar-accent-foreground"
              />
            }
          >
            <div className="bg-sidebar-primary text-sidebar-primary-foreground flex aspect-square size-8 items-center justify-center rounded-lg">
              {activeTeam.logo}
            </div>
            <div className="grid flex-1 text-left text-sm leading-tight">
              <span className="truncate font-medium">{activeTeam.name}</span>
              <span className="truncate text-xs">{activeTeam.plan}</span>
            </div>
            <IconPlaceholder
              lucide="ChevronsUpDownIcon"
              tabler="IconSelector"
              hugeicons="UnfoldMoreIcon"
              phosphor="CaretUpDownIcon"
              remixicon="RiArrowUpDownLine"
              className="ml-auto"
            />
          </DropdownMenuTrigger>
          <DropdownMenuContent
            className="min-w-56 rounded-lg"
            align="start"
            side={isMobile ? "bottom" : "right"}
            sideOffset={4}
          >
            <DropdownMenuGroup>
              <DropdownMenuLabel className="text-muted-foreground text-xs">
                Teams
              </DropdownMenuLabel>
              {teams.map((team, index) => (
                <DropdownMenuItem
                  key={team.name}
                  onClick={() => setActiveTeam(team)}
                  className="gap-2 p-2"
                >
                  <div className="flex size-6 items-center justify-center rounded-md border">
                    {team.logo}
                  </div>
                  {team.name}
                  <DropdownMenuShortcut>⌘{index + 1}</DropdownMenuShortcut>
                </DropdownMenuItem>
              ))}
            </DropdownMenuGroup>
            <DropdownMenuSeparator />
            <DropdownMenuGroup>
              <DropdownMenuItem className="gap-2 p-2">
                <div className="flex size-6 items-center justify-center rounded-md border bg-transparent">
                  <IconPlaceholder
                    lucide="PlusIcon"
                    tabler="IconPlus"
                    hugeicons="PlusSignIcon"
                    phosphor="PlusIcon"
                    remixicon="RiAddLine"
                    className="size-4"
                  />
                </div>
                <div className="text-muted-foreground font-medium">
                  Add team
                </div>
              </DropdownMenuItem>
            </DropdownMenuGroup>
          </DropdownMenuContent>
        </DropdownMenu>
      </SidebarMenuItem>
    </SidebarMenu>
  )
}

Subdomains

Functions

Dependencies

  • dropdown-menu
  • icon-placeholder
  • react
  • sidebar

Frequently Asked Questions

What does team-switcher.tsx do?
team-switcher.tsx is a source file in the ui codebase, written in tsx. It belongs to the ComponentRegistry domain, UIPrimitives subdomain.
What functions are defined in team-switcher.tsx?
team-switcher.tsx defines 1 function(s): TeamSwitcher.
What does team-switcher.tsx depend on?
team-switcher.tsx imports 4 module(s): dropdown-menu, icon-placeholder, react, sidebar.
Where is team-switcher.tsx in the architecture?
team-switcher.tsx is located at apps/v4/registry/bases/base/blocks/sidebar-07/components/team-switcher.tsx (domain: ComponentRegistry, subdomain: UIPrimitives, directory: apps/v4/registry/bases/base/blocks/sidebar-07/components).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free