diff --git a/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx b/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx index b86624ebd1008..0ed910c14c891 100644 --- a/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx +++ b/js_modules/dagster-ui/packages/ui-components/src/components/MiddleTruncate.tsx @@ -38,7 +38,7 @@ export const MiddleTruncate = ({text, showTitle = true}: Props) => { // Use a layout effect to trigger the process of calculating the truncated text, for the // initial render. - React.useEffect(() => { + React.useLayoutEffect(() => { window.requestAnimationFrame(calculateTargetStyle); }, [calculateTargetStyle]); diff --git a/js_modules/dagster-ui/packages/ui-components/src/components/PageHeader.tsx b/js_modules/dagster-ui/packages/ui-components/src/components/PageHeader.tsx index 3de87bda4b45d..7bb00ae5705cf 100644 --- a/js_modules/dagster-ui/packages/ui-components/src/components/PageHeader.tsx +++ b/js_modules/dagster-ui/packages/ui-components/src/components/PageHeader.tsx @@ -48,5 +48,6 @@ const PageHeaderContainer = styled(Box)` */ .bp5-breadcrumbs { height: auto; + min-height: 30px; } `; diff --git a/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx b/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx index 4a5aef68936ab..554b0754bdbce 100644 --- a/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx +++ b/js_modules/dagster-ui/packages/ui-components/src/components/__stories__/MiddleTruncate.stories.tsx @@ -1,6 +1,9 @@ +// eslint-disable-next-line no-restricted-imports +import {Breadcrumbs2 as Breadcrumbs} from '@blueprintjs/popover2'; import {Meta} from '@storybook/react'; import faker from 'faker'; import {useMemo, useRef, useState} from 'react'; +import styled from 'styled-components'; import {Box} from '../Box'; import {Colors} from '../Color'; @@ -8,6 +11,7 @@ import {Icon} from '../Icon'; import {MiddleTruncate} from '../MiddleTruncate'; import {Slider} from '../Slider'; import {Tag} from '../Tag'; +import {Heading, Title} from '../Text'; // eslint-disable-next-line import/no-default-export export default { @@ -240,3 +244,62 @@ export const Containers = () => { ); }; + +export const BreadcrumbsScenario = () => { + const breadcrumbs = [ + {text: 's3', href: '#'}, + {text: 'superdomain_1', href: '#'}, + {text: 'subdomain_1', href: '#'}, + {text: 'subsubsubsubdosubsubsubsubdoma', href: '#'}, + {text: 'asset1', href: '#'}, + ]; + return ( + + <Box flex={{alignItems: 'center', gap: 4}} style={{maxWidth: '500px'}}> + <BreadcrumbsWithSlashes + items={breadcrumbs} + currentBreadcrumbRenderer={({text, href}) => ( + <span key={href}> + <TruncatedHeading> + <MiddleTruncate text={text as string} /> + </TruncatedHeading> + </span> + )} + $numHeaderBreadcrumbs={breadcrumbs.length} + breadcrumbRenderer={({text, href}) => ( + <span key={href}> + <TruncatedHeading> + <MiddleTruncate text={text as string} /> + </TruncatedHeading> + </span> + )} + popoverProps={{ + minimal: true, + modifiers: {offset: {enabled: true, options: {offset: [0, 8]}}}, + popoverClassName: 'dagster-popover', + }} + /> + </Box> + + ); +}; + +const TruncatedHeading = styled(Heading)` + max-width: 200px; + overflow: hidden; +`; + +// Only add slashes within the asset key path +const BreadcrumbsWithSlashes = styled(Breadcrumbs)<{$numHeaderBreadcrumbs: number}>` + height: auto; + + & li:nth-child(n + ${(p) => p.$numHeaderBreadcrumbs + 1})::after { + background: none; + font-size: 20px; + font-weight: bold; + color: ${Colors.textLighter()}; + content: '/'; + width: 8px; + line-height: 16px; + } +`; diff --git a/js_modules/dagster-ui/packages/ui-core/src/assets/AssetPageHeader.oss.tsx b/js_modules/dagster-ui/packages/ui-core/src/assets/AssetPageHeader.oss.tsx index de0893e9357bd..fad106e3612ab 100644 --- a/js_modules/dagster-ui/packages/ui-core/src/assets/AssetPageHeader.oss.tsx +++ b/js_modules/dagster-ui/packages/ui-core/src/assets/AssetPageHeader.oss.tsx @@ -168,6 +168,13 @@ const BreadcrumbsWithSlashes = styled(Breadcrumbs)<{$numHeaderBreadcrumbs: numbe width: 8px; line-height: 16px; } + /** + * Blueprint breadcrumbs annoyingly have a built-in height. + */ + .bp5-breadcrumbs { + height: auto; + min-height: 30px; + } `; const BreadcrumbLink = styled(Link)`