mirror of
https://github.com/grafana/grafana.git
synced 2026-08-18 00:54:58 -05:00
improve responsiveness of breadcrumbs (#55572)
This commit is contained in:
@@ -37,7 +37,7 @@ export function NavToolbar({
|
|||||||
<div className={styles.menuButton}>
|
<div className={styles.menuButton}>
|
||||||
<IconButton name="bars" tooltip="Toggle menu" tooltipPlacement="bottom" size="xl" onClick={onToggleMegaMenu} />
|
<IconButton name="bars" tooltip="Toggle menu" tooltipPlacement="bottom" size="xl" onClick={onToggleMegaMenu} />
|
||||||
</div>
|
</div>
|
||||||
<Breadcrumbs breadcrumbs={breadcrumbs} />
|
<Breadcrumbs breadcrumbs={breadcrumbs} className={styles.breadcrumbs} />
|
||||||
<div className={styles.actions}>
|
<div className={styles.actions}>
|
||||||
{actions}
|
{actions}
|
||||||
{actions && <NavToolbarSeparator />}
|
{actions && <NavToolbarSeparator />}
|
||||||
@@ -54,6 +54,9 @@ export function NavToolbar({
|
|||||||
|
|
||||||
const getStyles = (theme: GrafanaTheme2) => {
|
const getStyles = (theme: GrafanaTheme2) => {
|
||||||
return {
|
return {
|
||||||
|
breadcrumbs: css({
|
||||||
|
maxWidth: '50%',
|
||||||
|
}),
|
||||||
pageToolbar: css({
|
pageToolbar: css({
|
||||||
height: TOP_BAR_LEVEL_HEIGHT,
|
height: TOP_BAR_LEVEL_HEIGHT,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|||||||
@@ -39,8 +39,9 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
breadcrumb: css({
|
breadcrumb: css({
|
||||||
alignItems: 'center',
|
display: 'block',
|
||||||
display: 'flex',
|
textOverflow: 'ellipsis',
|
||||||
|
overflow: 'hidden',
|
||||||
padding: theme.spacing(0, 0.5),
|
padding: theme.spacing(0, 0.5),
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
}),
|
}),
|
||||||
@@ -53,7 +54,10 @@ const getStyles = (theme: GrafanaTheme2) => {
|
|||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
color: theme.colors.text.primary,
|
color: theme.colors.text.primary,
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
flex: 1,
|
||||||
fontWeight: theme.typography.fontWeightMedium,
|
fontWeight: theme.typography.fontWeightMedium,
|
||||||
|
minWidth: 0,
|
||||||
|
maxWidth: 'max-content',
|
||||||
|
|
||||||
// logic for small screens
|
// logic for small screens
|
||||||
// hide any breadcrumbs that aren't the second to last child (the parent)
|
// hide any breadcrumbs that aren't the second to last child (the parent)
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ import { Breadcrumb } from './types';
|
|||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
breadcrumbs: Breadcrumb[];
|
breadcrumbs: Breadcrumb[];
|
||||||
|
className?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Breadcrumbs({ breadcrumbs }: Props) {
|
export function Breadcrumbs({ breadcrumbs, className }: Props) {
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<nav aria-label="Breadcrumbs">
|
<nav aria-label="Breadcrumbs" className={className}>
|
||||||
<ol className={styles.breadcrumbs}>
|
<ol className={styles.breadcrumbs}>
|
||||||
{breadcrumbs.map((breadcrumb, index) => (
|
{breadcrumbs.map((breadcrumb, index) => (
|
||||||
<BreadcrumbItem {...breadcrumb} isCurrent={index === breadcrumbs.length - 1} key={index} />
|
<BreadcrumbItem {...breadcrumb} isCurrent={index === breadcrumbs.length - 1} key={index} />
|
||||||
|
|||||||
Reference in New Issue
Block a user