|
|
|
@ -10,9 +10,11 @@ import { Breadcrumb } from './types'; |
|
|
|
|
|
|
|
|
|
type Props = Breadcrumb & { |
|
|
|
|
isCurrent: boolean; |
|
|
|
|
index: number; |
|
|
|
|
flexGrow: number; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
export function BreadcrumbItem({ href, isCurrent, text }: Props) { |
|
|
|
|
export function BreadcrumbItem({ href, isCurrent, text, index, flexGrow }: Props) { |
|
|
|
|
const styles = useStyles2(getStyles); |
|
|
|
|
|
|
|
|
|
const onBreadcrumbClick = () => { |
|
|
|
@ -20,9 +22,14 @@ export function BreadcrumbItem({ href, isCurrent, text }: Props) { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<li className={styles.breadcrumbWrapper}> |
|
|
|
|
<li className={styles.breadcrumbWrapper} style={{ flexGrow }}> |
|
|
|
|
{isCurrent ? ( |
|
|
|
|
<span data-testid={Components.Breadcrumbs.breadcrumb(text)} className={styles.breadcrumb} aria-current="page"> |
|
|
|
|
<span |
|
|
|
|
data-testid={Components.Breadcrumbs.breadcrumb(text)} |
|
|
|
|
className={styles.breadcrumb} |
|
|
|
|
aria-current="page" |
|
|
|
|
title={text} |
|
|
|
|
> |
|
|
|
|
{text} |
|
|
|
|
</span> |
|
|
|
|
) : ( |
|
|
|
@ -31,6 +38,7 @@ export function BreadcrumbItem({ href, isCurrent, text }: Props) { |
|
|
|
|
onClick={onBreadcrumbClick} |
|
|
|
|
data-testid={Components.Breadcrumbs.breadcrumb(text)} |
|
|
|
|
className={cx(styles.breadcrumb, styles.breadcrumbLink)} |
|
|
|
|
title={text} |
|
|
|
|
href={href} |
|
|
|
|
> |
|
|
|
|
{text} |
|
|
|
@ -45,10 +53,6 @@ export function BreadcrumbItem({ href, isCurrent, text }: Props) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => { |
|
|
|
|
const separator = css({ |
|
|
|
|
color: theme.colors.text.secondary, |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
breadcrumb: css({ |
|
|
|
|
display: 'block', |
|
|
|
@ -75,25 +79,19 @@ const getStyles = (theme: GrafanaTheme2) => { |
|
|
|
|
// logic for small screens
|
|
|
|
|
// hide any breadcrumbs that aren't the second to last child (the parent)
|
|
|
|
|
// unless there's only one breadcrumb, in which case we show it
|
|
|
|
|
[theme.breakpoints.down('md')]: { |
|
|
|
|
[theme.breakpoints.down('sm')]: { |
|
|
|
|
display: 'none', |
|
|
|
|
'&:nth-last-child(2)': { |
|
|
|
|
display: 'flex', |
|
|
|
|
flexDirection: 'row-reverse', |
|
|
|
|
|
|
|
|
|
[`.${separator}`]: { |
|
|
|
|
transform: 'rotate(180deg)', |
|
|
|
|
}, |
|
|
|
|
minWidth: '40px', |
|
|
|
|
}, |
|
|
|
|
'&:first-child&:last-child': { |
|
|
|
|
'&:last-child': { |
|
|
|
|
display: 'flex', |
|
|
|
|
|
|
|
|
|
[`.${separator}`]: { |
|
|
|
|
display: 'none', |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}), |
|
|
|
|
separator, |
|
|
|
|
separator: css({ |
|
|
|
|
color: theme.colors.text.secondary, |
|
|
|
|
}), |
|
|
|
|
}; |
|
|
|
|
}; |
|
|
|
|