Skip to content

Commit

Permalink
[Asset graph] Add animations for in progress / queued materialization…
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm authored Mar 19, 2024
1 parent c244349 commit c2a01b9
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,5 @@ export {
colorDataVizVioletAlt as dataVizVioletAlt,
colorDataVizYellow as dataVizYellow,
colorDataVizYellowAlt as dataVizYellowAlt,
replaceAlpha,
} from '../theme/color';
23 changes: 23 additions & 0 deletions js_modules/dagster-ui/packages/ui-components/src/theme/color.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,29 @@ const getColor = memoize((semanticName: ColorName): string => {
return palette[semanticName];
});

export function replaceAlpha(rgbaString: string, newAlpha: number) {
// Check if the input string is in the correct format
const rgbaRegex = /^rgba?\((\s*\d+\s*),(\s*\d+\s*),(\s*\d+\s*),(\s*[\d.]+\s*)\)$/;
const match = rgbaString.match(rgbaRegex);
if (!match) {
console.error('Invalid RGBA string format.');
return null;
}

// Extract RGB values
const red = parseInt(match[1]!.trim(), 10);
const green = parseInt(match[2]!.trim(), 10);
const blue = parseInt(match[3]!.trim(), 10);

// Ensure alpha value is within the range [0, 1]
const clampedAlpha = Math.max(0, Math.min(newAlpha, 1));

// Construct the new RGBA string with the updated alpha value
const newRgbaString = `rgba(${red},${green},${blue},${clampedAlpha})`;

return newRgbaString;
}

export const browserColorScheme = () => getColor(ColorName.BrowserColorScheme);
export const colorKeylineDefault = () => getColor(ColorName.KeylineDefault);
export const colorLinkDefault = () => getColor(ColorName.LinkDefault);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import styled, {CSSObject} from 'styled-components';

import {AssetNodeMenuProps, useAssetNodeMenu} from './AssetNodeMenu';
import {buildAssetNodeStatusContent} from './AssetNodeStatusContent';
import {AssetLatestRunSpinner} from './AssetRunLinking';
import {ContextMenuWrapper} from './ContextMenuWrapper';
import {LiveDataForNode} from './Utils';
import {ASSET_NODE_NAME_MAX_LENGTH} from './layout';
Expand All @@ -31,7 +30,6 @@ export const AssetNode = React.memo(({definition, selected}: Props) => {
const isSource = definition.isSource;

const {liveData} = useAssetLiveData(definition.assetKey);

return (
<AssetInsetForHoverEffect>
<Box
Expand Down Expand Up @@ -189,6 +187,9 @@ export const AssetNodeMinimal = ({
const isChanged = definition.changedReasons.length;
const isStale = isAssetStale(assetKey, liveData, 'upstream');

const queuedRuns = liveData?.unstartedRunIds.length;
const inProgressRuns = liveData?.inProgressRunIds.length;

return (
<AssetInsetForHoverEffect>
<MinimalAssetNodeContainer $selected={selected} style={{paddingTop: height / 2 - 50}}>
Expand All @@ -203,6 +204,8 @@ export const AssetNodeMinimal = ({
$isSource={isSource}
$background={background}
$border={border}
$inProgress={!!inProgressRuns}
$isQueued={!!queuedRuns}
>
{isChanged ? (
<MinimalNodeChangedDot
Expand All @@ -213,9 +216,6 @@ export const AssetNodeMinimal = ({
{isStale ? (
<MinimalNodeStaleDot assetKey={assetKey} liveData={liveData} include="upstream" />
) : null}
<AssetNodeSpinnerContainer>
<AssetLatestRunSpinner liveData={liveData} purpose="section" />
</AssetNodeSpinnerContainer>
<MinimalName style={{fontSize: 28}} $isSource={isSource}>
{withMiddleTruncation(displayName, {maxLength: 20})}
</MinimalName>
Expand Down Expand Up @@ -337,12 +337,6 @@ const AssetName = styled.div<{$isSource: boolean}>`
border-top-right-radius: 8px;
`;

const AssetNodeSpinnerContainer = styled.div`
top: 50%;
position: absolute;
transform: translate(8px, -16px);
`;

const MinimalAssetNodeContainer = styled(AssetNodeContainer)`
height: 100%;
`;
Expand All @@ -352,13 +346,59 @@ const MinimalAssetNodeBox = styled.div<{
$selected: boolean;
$background: string;
$border: string;
$inProgress: boolean;
$isQueued: boolean;
}>`
background: ${(p) => p.$background};
overflow: hidden;
${(p) =>
p.$isSource
? `border: 4px dashed ${p.$selected ? Colors.accentGray() : p.$border}`
: `border: 4px solid ${p.$selected ? Colors.lineageNodeBorderSelected() : p.$border}`};
${(p) =>
p.$inProgress
? `
background-color: ${p.$background};
&::after {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
transform: translateX(-100%);
background-image: linear-gradient(90deg, ${Colors.replaceAlpha(
p.$background,
0,
)} 0, ${Colors.replaceAlpha(p.$background, 0)} 0%, ${Colors.replaceAlpha(
p.$background,
0.2,
)});
animation: shimmer 1.5s infinite;
content: '';
}
@keyframes shimmer {
100% {
transform: translateX(100%);
}
}
`
: ''}
${(p) =>
p.$isQueued
? `
animation: pulse 0.75s infinite alternate;
@keyframes pulse {
0% {
border-color: ${Colors.replaceAlpha(p.$border, 0.2)};
}
100% {
border-color: ${Colors.replaceAlpha(p.$border, 1)};
}
}
`
: ''}
border-radius: 16px;
position: relative;
padding: 2px;
Expand Down

2 comments on commit c2a01b9

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-storybook ready!

✅ Preview
https://dagit-storybook-a408fh0w8-elementl.vercel.app

Built with commit c2a01b9.
This pull request is being automatically deployed with vercel-action

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for dagit-core-storybook ready!

✅ Preview
https://dagit-core-storybook-9eowlxt2u-elementl.vercel.app

Built with commit c2a01b9.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.