Skip to content

Commit 2a8192b

Browse files
authored
fix(ui) Fix rendering of hatched bars in firefox (#21140)
Firefox has a hard time with subpixel aliasing which results in really jagged looking hatching. Widening the hatching a bit enables better rendering in firefox and consistent results across browsers.
1 parent 7465b6f commit 2a8192b

File tree

3 files changed

+44
-27
lines changed

3 files changed

+44
-27
lines changed

src/sentry/static/sentry/app/components/events/interfaces/spans/spanBar.tsx

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {
3131
MINIMAP_SPAN_BAR_HEIGHT,
3232
NUM_OF_SPANS_FIT_IN_MINI_MAP,
3333
} from './header';
34-
import {SPAN_ROW_HEIGHT, SpanRow, zIndex} from './styles';
34+
import {SPAN_ROW_HEIGHT, SpanRow, zIndex, getHatchPattern} from './styles';
3535
import * as DividerHandlerManager from './dividerHandlerManager';
3636
import * as CursorGuideHandler from './cursorGuideHandler';
3737
import SpanDetail from './spanDetail';
@@ -1100,25 +1100,14 @@ const DurationPill = styled('div')<{
11001100
}
11011101
`;
11021102

1103-
const getHatchPattern = ({spanBarHatch}) => {
1104-
if (spanBarHatch === true) {
1105-
return `
1106-
background-image: linear-gradient(45deg, #dedae3 10%, #f4f2f7 10%, #f4f2f7 50%, #dedae3 50%, #dedae3 60%, #f4f2f7 60%, #f4f2f7 100%);
1107-
background-size: 6.5px 6.5px;
1108-
`;
1109-
}
1110-
1111-
return null;
1112-
};
1113-
11141103
export const SpanBarRectangle = styled('div')<{spanBarHatch: boolean}>`
11151104
position: relative;
11161105
height: 100%;
11171106
min-width: 1px;
11181107
user-select: none;
11191108
transition: border-color 0.15s ease-in-out;
11201109
border-right: 1px solid rgba(0, 0, 0, 0);
1121-
${getHatchPattern}
1110+
${p => getHatchPattern(p, '#dedae3', '#f4f2f7')}
11221111
`;
11231112

11241113
const StyledIconWarning = styled(IconWarning)`

src/sentry/static/sentry/app/components/events/interfaces/spans/styles.tsx

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,38 @@ export const SpanRowMessage = styled(SpanRow)`
5454
margin-left: ${space(2)};
5555
}
5656
`;
57+
58+
type HatchProps = {
59+
spanBarHatch: boolean;
60+
};
61+
62+
export function getHatchPattern(
63+
{spanBarHatch}: HatchProps,
64+
primary: string,
65+
alternate: string
66+
) {
67+
if (spanBarHatch === true) {
68+
return `
69+
background-image: linear-gradient(135deg,
70+
${alternate},
71+
${alternate} 2.5px,
72+
${primary} 2.5px,
73+
${primary} 5px,
74+
${alternate} 6px,
75+
${alternate} 8px,
76+
${primary} 8px,
77+
${primary} 11px,
78+
${alternate} 11px,
79+
${alternate} 14px,
80+
${primary} 14px,
81+
${primary} 16.5px,
82+
${alternate} 16.5px,
83+
${alternate} 19px,
84+
${primary} 20px
85+
);
86+
background-size: 16px 16px;
87+
`;
88+
}
89+
90+
return null;
91+
}

src/sentry/static/sentry/app/views/performance/compare/spanBar.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import theme from 'app/utils/theme';
66
import space from 'app/styles/space';
77
import Count from 'app/components/count';
88
import {TreeDepthType} from 'app/components/events/interfaces/spans/types';
9-
import {SPAN_ROW_HEIGHT, SpanRow} from 'app/components/events/interfaces/spans/styles';
9+
import {
10+
SPAN_ROW_HEIGHT,
11+
SpanRow,
12+
getHatchPattern,
13+
} from 'app/components/events/interfaces/spans/styles';
1014
import {
1115
TOGGLE_BORDER_BOX,
1216
SpanRowCellContainer,
@@ -511,22 +515,11 @@ class SpanBar extends React.Component<Props, State> {
511515
}
512516
}
513517

514-
const getHatchPattern = ({spanBarHatch}) => {
515-
if (spanBarHatch === true) {
516-
return `
517-
background-image: linear-gradient(135deg, #9f92fa 33.33%, #302839 33.33%, #302839 50%, #9f92fa 50%, #9f92fa 83.33%, #302839 83.33%, #302839 100%);
518-
background-size: 4.24px 4.24px;
519-
`;
520-
}
521-
522-
return null;
523-
};
524-
525-
const ComparisonSpanBarRectangle = styled(SpanBarRectangle)`
518+
const ComparisonSpanBarRectangle = styled(SpanBarRectangle)<{spanBarHatch: boolean}>`
526519
position: absolute;
527520
left: 0;
528521
height: 16px;
529-
${getHatchPattern};
522+
${p => getHatchPattern(p, theme.purple300, theme.gray700)}
530523
`;
531524

532525
const ComparisonLabel = styled('div')`

0 commit comments

Comments
 (0)