import { ArrowDropDown, ArrowForwardIos, Close } from '@mui/icons-material' import clsx from 'clsx' import { useState } from 'react' import { useTranslation } from 'react-i18next' import { BreadcrumbsProps, DaoPageMode } from '@dao-dao/types' import { useDaoIfAvailable } from '../../contexts' import { useDaoNavHelpers } from '../../hooks' import { Button } from '../buttons/Button' import { IconButton } from '../icon_buttons/IconButton' import { LinkWrapper } from '../LinkWrapper' import { Tooltip } from '../tooltip' import { useAppContext } from './AppContext' export const Breadcrumbs = ({ home = false, override = false, homeTab, current, dao: _dao, className, }: BreadcrumbsProps) => { const { t } = useTranslation() const { mode } = useAppContext() const { getDaoPath } = useDaoNavHelpers() // Allow using Breadcrumbs outside of DaoPageWrapper. const dao = useDaoIfAvailable() || _dao const [responsive, setResponsive] = useState(false) const crumbs = mode === DaoPageMode.Dapp ? home || !dao ? [{ href: '/', label: t('title.home') }] : [ { href: // Link to home tab if available. getDaoPath(dao.coreAddress, homeTab?.id), label: dao.name, }, ] : // SDA home || !dao ? [] : [ { href: // Link to home tab if available. getDaoPath(dao.coreAddress, homeTab?.id), label: homeTab?.sdaLabel || t('title.home'), }, ] const hasCrumbs = crumbs.length > 0 return ( <>
{crumbs.map(({ href, label }, idx) => { // If not first or last crumb, show ellipsis. const firstOrLast = idx === 0 || idx === crumbs.length - 1 return (
2 && 'max-w-[12rem]' )} href={href} > {firstOrLast ? label : '...'}
) })} {override ? ( current ) : ( )}
setResponsive(false)} >
{crumbs.map(({ href, label }, idx) => (
{label}

/

))}
setResponsive(false)} size="lg" variant="secondary" />
) }