Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Asset graph] Add animations for in progress / queued materialization state #20556

Merged
merged 3 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would be nice to also require match.length === 3 or 4 here, just in case since it's required on lines 21-23

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the regex requires that by the number of matches in it

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 @@ -32,7 +31,6 @@ export const AssetNode = React.memo(({definition, selected}: Props) => {
const isSource = definition.isSource;

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

return (
<AssetInsetForHoverEffect>
<Box flex={{direction: 'row', justifyContent: 'space-between', alignItems: 'center'}}>
Expand Down Expand Up @@ -179,6 +177,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 @@ -193,6 +194,8 @@ export const AssetNodeMinimal = ({
$isSource={isSource}
$background={background}
$border={border}
$inProgress={!!inProgressRuns}
$isQueued={!!queuedRuns}
>
{isChanged ? (
<MinimalNodeChangedDot
Expand All @@ -203,9 +206,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 @@ -323,12 +323,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 @@ -338,13 +332,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
Loading