Skip to content

Commit

Permalink
[ui] Replace uses of replaceAlpha in asset graph, not possible with n…
Browse files Browse the repository at this point in the history
…ew vars

Fixes FE-341
  • Loading branch information
bengotow committed May 2, 2024
1 parent bc81704 commit 24cc922
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 42 deletions.
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

0 comments on commit 24cc922

Please sign in to comment.