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

[ui] Replace uses of replaceAlpha in asset graph, not possible with new vars #21589

Merged
merged 1 commit into from
May 2, 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,6 +116,5 @@ export {
colorDataVizVioletAlt as dataVizVioletAlt,
colorDataVizYellow as dataVizYellow,
colorDataVizYellowAlt as dataVizYellowAlt,
replaceAlpha,
colorBlueGradient as blueGradient,
} from '../theme/color';
23 changes: 0 additions & 23 deletions js_modules/dagster-ui/packages/ui-components/src/theme/color.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,6 @@
import {ColorName} from '../palettes/ColorName';
import {colorNameToVar} from '../palettes/colorNameToVar';

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 = () => colorNameToVar[ColorName.BrowserColorScheme];
export const colorKeylineDefault = () => colorNameToVar[ColorName.KeylineDefault];
export const colorLinkDefault = () => colorNameToVar[ColorName.LinkDefault];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,19 +362,11 @@ const MinimalAssetNodeBox = styled.div<{
? `
background-color: ${p.$background};
&::after {
inset: 0;
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,
)});
mask-image: linear-gradient(90deg, rgba(255,255,255,0) 0, rgba(255,255,255,0) 0%, rgba(255,255,255,0.3));
background: ${p.$background};
animation: shimmer 1.5s infinite;
content: '';
}
Expand All @@ -390,15 +382,23 @@ const MinimalAssetNodeBox = styled.div<{
${(p) =>
p.$isQueued
? `
border: none;
&::after {
inset: 0;
position: absolute;
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;
border: 4px solid ${p.$border};
content: '';
}
@keyframes pulse {
0% {
opacity: 0.2;
}
100% {
opacity: 1;
}
}
`
: ''}
border-radius: 16px;
Expand Down