import type { ButtonHTMLAttributes } from 'react' import { SidebarV2TokensType } from './sidebarV2.tokens' import type { SecondarySidebarInfo, SecondarySidebarItem } from './types' import Block from '../Primitives/Block/Block' import PrimitiveButton from '../Primitives/PrimitiveButton/PrimitiveButton' import { TooltipV2, TooltipV2Side, TooltipV2Size } from '../TooltipV2' import { Badge, BadgeColor, BadgeSize } from '../Badge' import styled from 'styled-components' const ScrollableContainer = styled(Block)` &::-webkit-scrollbar { display: none; width: 0; height: 0; } -ms-overflow-style: none; scrollbar-width: none; scrollbar-color: transparent transparent; ` type Props = { id: string secondarySidebar?: SecondarySidebarInfo isExpanded?: boolean tokens: SidebarV2TokensType } type SecondarySidebarItemButtonProps = { item: SecondarySidebarItem isSelected: boolean onSelect: (value: string) => void buttonProps?: ButtonHTMLAttributes tokens: SidebarV2TokensType } function SecondarySidebarItemButton({ item, isSelected, onSelect, buttonProps, tokens, }: SecondarySidebarItemButtonProps) { const itemButton = ( { onSelect(item.value) buttonProps?.onClick?.(e) }} aria-label={`Select tenant: ${item.label}`} aria-pressed={isSelected} > ) const trigger = item.badge ? ( {itemButton} ) : ( itemButton ) return ( {trigger} ) } export function SecondarySidebar({ id, secondarySidebar, isExpanded = true, tokens, }: Props) { if (!secondarySidebar || (secondarySidebar?.items?.length ?? 0) === 0) { return null } const { items, footerSlot, selected, onSelect, buttonProps } = secondarySidebar const isSelected = (value: string) => value === selected return ( {items?.map((item) => ( ))} {footerSlot && ( {footerSlot} )} ) }