| 1 | /** |
| 2 | * MyChannelsEntry - 我的频道入口组件 |
| 3 | */ |
| 4 | |
| 5 | 'use client' |
| 6 | |
| 7 | import type { SidebarCommonProps } from '../../types' |
| 8 | import { Tv } from 'lucide-react' |
| 9 | import { useTransClient } from '@/app/i18n/client' |
| 10 | import { useChannelManagerStore } from '@/components/ChannelManager' |
| 11 | import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip' |
| 12 | import { cn } from '@/utils/className' |
| 13 | |
| 14 | export function MyChannelsEntry({ collapsed }: SidebarCommonProps) { |
| 15 | const { t } = useTransClient('account') |
| 16 | const openModal = useChannelManagerStore(state => state.openModal) |
| 17 | |
| 18 | const handleClick = () => { |
| 19 | openModal() |
| 20 | } |
| 21 | |
| 22 | return ( |
| 23 | <TooltipProvider> |
| 24 | <Tooltip> |
| 25 | <TooltipTrigger asChild> |
| 26 | <button |
| 27 | type="button" |
| 28 | onClick={handleClick} |
| 29 | data-testid="sidebar-my-channels" |
| 30 | className={cn( |
| 31 | 'flex flex-1 cursor-pointer items-center rounded-lg text-muted-foreground transition-colors hover:bg-brand-cyan/10 hover:text-brand-cyan', |
| 32 | collapsed ? 'h-9 w-9 justify-center' : 'justify-between px-3 py-2', |
| 33 | )} |
| 34 | > |
| 35 | <div className="flex items-center gap-2"> |
| 36 | <Tv size={18} className="text-brand-cyan" /> |
| 37 | {!collapsed && <span className="text-sm">{t('channelManager.myChannels')}</span>} |
| 38 | </div> |
| 39 | </button> |
| 40 | </TooltipTrigger> |
| 41 | {collapsed && ( |
| 42 | <TooltipContent side="right"> |
| 43 | <p>{t('channelManager.myChannels')}</p> |
| 44 | </TooltipContent> |
| 45 | )} |
| 46 | </Tooltip> |
| 47 | </TooltipProvider> |
| 48 | ) |
| 49 | } |
| 50 |