import { css, createElement } from '@remix-run/ui' import type { Handle, Props, RemixNode } from '@remix-run/ui' import { Glyph } from '../glyph/glyph.tsx' import { theme } from '../../theme/theme.ts' export type BreadcrumbItem = { current?: boolean href?: string label: RemixNode } export type BreadcrumbsProps = Omit, 'children'> & { items: BreadcrumbItem[] separator?: RemixNode } const rootCss = css({ minWidth: 0, }) const listCss = css({ display: 'flex', flexWrap: 'wrap', alignItems: 'center', gap: `${theme.space.xs} ${theme.space.sm}`, minWidth: 0, margin: 0, padding: 0, listStyle: 'none', }) const itemCss = css({ display: 'inline-flex', alignItems: 'center', minWidth: 0, }) const separatorCss = css({ display: 'inline-flex', alignItems: 'center', justifyContent: 'center', flexShrink: 0, width: theme.fontSize.sm, height: theme.fontSize.sm, color: theme.colors.text.muted, }) const linkCss = css({ color: theme.colors.text.secondary, fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.normal, textDecoration: 'none', whiteSpace: 'nowrap', '&:hover': { color: theme.colors.text.primary, }, }) const currentCss = css({ color: theme.colors.text.primary, fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.normal, fontWeight: theme.fontWeight.medium, whiteSpace: 'nowrap', }) const textCss = css({ color: theme.colors.text.secondary, fontSize: theme.fontSize.sm, lineHeight: theme.lineHeight.normal, whiteSpace: 'nowrap', }) export function Breadcrumbs(handle: Handle): () => RemixNode { return () => { let { 'aria-label': ariaLabel, items, separator, mix, ...navProps } = handle.props let currentIndex = items.findIndex((item) => item.current) if (currentIndex === -1) { currentIndex = Math.max(0, items.length - 1) } let separatorContent = separator ?? return ( ) } }