Skip to content

Commit b7995ae

Browse files
authored
Chore: Rewrite grafana-flamegraph css using object styles (grafana#86816)
1 parent 5dea949 commit b7995ae

File tree

6 files changed

+166
-211
lines changed

6 files changed

+166
-211
lines changed

.betterer.results

-40
Original file line numberDiff line numberDiff line change
@@ -454,46 +454,6 @@ exports[`better eslint`] = {
454454
"packages/grafana-data/test/__mocks__/pluginMocks.ts:5381": [
455455
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
456456
],
457-
"packages/grafana-flamegraph/src/FlameGraph/FlameGraph.tsx:5381": [
458-
[0, 0, 0, "Styles should be written using objects.", "0"],
459-
[0, 0, 0, "Styles should be written using objects.", "1"],
460-
[0, 0, 0, "Styles should be written using objects.", "2"],
461-
[0, 0, 0, "Styles should be written using objects.", "3"],
462-
[0, 0, 0, "Styles should be written using objects.", "4"]
463-
],
464-
"packages/grafana-flamegraph/src/FlameGraph/FlameGraphMetadata.tsx:5381": [
465-
[0, 0, 0, "Styles should be written using objects.", "0"],
466-
[0, 0, 0, "Styles should be written using objects.", "1"],
467-
[0, 0, 0, "Styles should be written using objects.", "2"],
468-
[0, 0, 0, "Styles should be written using objects.", "3"]
469-
],
470-
"packages/grafana-flamegraph/src/FlameGraph/FlameGraphTooltip.tsx:5381": [
471-
[0, 0, 0, "Styles should be written using objects.", "0"],
472-
[0, 0, 0, "Styles should be written using objects.", "1"],
473-
[0, 0, 0, "Styles should be written using objects.", "2"],
474-
[0, 0, 0, "Styles should be written using objects.", "3"],
475-
[0, 0, 0, "Styles should be written using objects.", "4"],
476-
[0, 0, 0, "Styles should be written using objects.", "5"]
477-
],
478-
"packages/grafana-flamegraph/src/FlameGraphHeader.tsx:5381": [
479-
[0, 0, 0, "Styles should be written using objects.", "0"],
480-
[0, 0, 0, "Styles should be written using objects.", "1"],
481-
[0, 0, 0, "Styles should be written using objects.", "2"],
482-
[0, 0, 0, "Styles should be written using objects.", "3"],
483-
[0, 0, 0, "Styles should be written using objects.", "4"],
484-
[0, 0, 0, "Styles should be written using objects.", "5"],
485-
[0, 0, 0, "Styles should be written using objects.", "6"],
486-
[0, 0, 0, "Styles should be written using objects.", "7"],
487-
[0, 0, 0, "Styles should be written using objects.", "8"],
488-
[0, 0, 0, "Styles should be written using objects.", "9"],
489-
[0, 0, 0, "Styles should be written using objects.", "10"],
490-
[0, 0, 0, "Styles should be written using objects.", "11"],
491-
[0, 0, 0, "Styles should be written using objects.", "12"]
492-
],
493-
"packages/grafana-flamegraph/src/TopTable/FlameGraphTopTableContainer.tsx:5381": [
494-
[0, 0, 0, "Styles should be written using objects.", "0"],
495-
[0, 0, 0, "Styles should be written using objects.", "1"]
496-
],
497457
"packages/grafana-o11y-ds-frontend/src/utils.ts:5381": [
498458
[0, 0, 0, "Do not use any type assertions.", "0"]
499459
],

packages/grafana-flamegraph/src/FlameGraph/FlameGraph.tsx

+26-27
Original file line numberDiff line numberDiff line change
@@ -185,33 +185,32 @@ const FlameGraph = ({
185185
};
186186

187187
const getStyles = () => ({
188-
graph: css`
189-
label: graph;
190-
overflow: auto;
191-
flex-grow: 1;
192-
flex-basis: 50%;
193-
`,
194-
sandwichCanvasWrapper: css`
195-
label: sandwichCanvasWrapper;
196-
display: flex;
197-
margin-bottom: ${PIXELS_PER_LEVEL / window.devicePixelRatio}px;
198-
`,
199-
sandwichMarker: css`
200-
label: sandwichMarker;
201-
writing-mode: vertical-lr;
202-
transform: rotate(180deg);
203-
overflow: hidden;
204-
white-space: nowrap;
205-
`,
206-
207-
sandwichMarkerCalees: css`
208-
label: sandwichMarkerCalees;
209-
text-align: right;
210-
`,
211-
sandwichMarkerIcon: css`
212-
label: sandwichMarkerIcon;
213-
vertical-align: baseline;
214-
`,
188+
graph: css({
189+
label: 'graph',
190+
overflow: 'auto',
191+
flexGrow: 1,
192+
flexBasis: '50%',
193+
}),
194+
sandwichCanvasWrapper: css({
195+
label: 'sandwichCanvasWrapper',
196+
display: 'flex',
197+
marginBottom: `${PIXELS_PER_LEVEL / window.devicePixelRatio}px`,
198+
}),
199+
sandwichMarker: css({
200+
label: 'sandwichMarker',
201+
writingMode: 'vertical-lr',
202+
transform: 'rotate(180deg)',
203+
overflow: 'hidden',
204+
whiteSpace: 'nowrap',
205+
}),
206+
sandwichMarkerCalees: css({
207+
label: 'sandwichMarkerCalees',
208+
textAlign: 'right',
209+
}),
210+
sandwichMarkerIcon: css({
211+
label: 'sandwichMarkerIcon',
212+
verticalAlign: 'baseline',
213+
}),
215214
});
216215

217216
export default FlameGraph;

packages/grafana-flamegraph/src/FlameGraph/FlameGraphMetadata.tsx

+29-30
Original file line numberDiff line numberDiff line change
@@ -89,36 +89,35 @@ const FlameGraphMetadata = React.memo(
8989
FlameGraphMetadata.displayName = 'FlameGraphMetadata';
9090

9191
const getStyles = (theme: GrafanaTheme2) => ({
92-
metadataPill: css`
93-
label: metadataPill;
94-
display: inline-flex;
95-
align-items: center;
96-
background: ${theme.colors.background.secondary};
97-
border-radius: ${theme.shape.borderRadius(8)};
98-
padding: ${theme.spacing(0.5, 1)};
99-
font-size: ${theme.typography.bodySmall.fontSize};
100-
font-weight: ${theme.typography.fontWeightMedium};
101-
line-height: ${theme.typography.bodySmall.lineHeight};
102-
color: ${theme.colors.text.secondary};
103-
`,
104-
105-
pillCloseButton: css`
106-
label: pillCloseButton;
107-
vertical-align: text-bottom;
108-
margin: ${theme.spacing(0, 0.5)};
109-
`,
110-
metadata: css`
111-
margin: 8px 0;
112-
text-align: center;
113-
`,
114-
metadataPillName: css`
115-
label: metadataPillName;
116-
max-width: 200px;
117-
overflow: hidden;
118-
text-overflow: ellipsis;
119-
white-space: nowrap;
120-
margin-left: ${theme.spacing(0.5)};
121-
`,
92+
metadataPill: css({
93+
label: 'metadataPill',
94+
display: 'inline-flex',
95+
alignItems: 'center',
96+
background: theme.colors.background.secondary,
97+
borderRadius: theme.shape.borderRadius(8),
98+
padding: theme.spacing(0.5, 1),
99+
fontSize: theme.typography.bodySmall.fontSize,
100+
fontWeight: theme.typography.fontWeightMedium,
101+
lineHeight: theme.typography.bodySmall.lineHeight,
102+
color: theme.colors.text.secondary,
103+
}),
104+
pillCloseButton: css({
105+
label: 'pillCloseButton',
106+
verticalAlign: 'text-bottom',
107+
margin: theme.spacing(0, 0.5),
108+
}),
109+
metadata: css({
110+
margin: '8px 0',
111+
textAlign: 'center',
112+
}),
113+
metadataPillName: css({
114+
label: 'metadataPillName',
115+
maxWidth: '200px',
116+
overflow: 'hidden',
117+
textOverflow: 'ellipsis',
118+
whiteSpace: 'nowrap',
119+
marginLeft: theme.spacing(0.5),
120+
}),
122121
});
123122

124123
export default FlameGraphMetadata;

packages/grafana-flamegraph/src/FlameGraph/FlameGraphTooltip.tsx

+27-27
Original file line numberDiff line numberDiff line change
@@ -182,33 +182,33 @@ function getValueWithUnit(data: FlameGraphDataContainer, displayValue: DisplayVa
182182
}
183183

184184
const getStyles = (theme: GrafanaTheme2) => ({
185-
tooltipContainer: css`
186-
title: tooltipContainer;
187-
overflow: hidden;
188-
`,
189-
tooltipContent: css`
190-
title: tooltipContent;
191-
font-size: ${theme.typography.bodySmall.fontSize};
192-
width: 100%;
193-
`,
194-
tooltipName: css`
195-
title: tooltipName;
196-
margin-top: 0;
197-
word-break: break-all;
198-
`,
199-
lastParagraph: css`
200-
title: lastParagraph;
201-
margin-bottom: 0;
202-
`,
203-
name: css`
204-
title: name;
205-
margin-bottom: 10px;
206-
`,
207-
208-
tooltipTable: css`
209-
title: tooltipTable;
210-
max-width: 400px;
211-
`,
185+
tooltipContainer: css({
186+
title: 'tooltipContainer',
187+
overflow: 'hidden',
188+
}),
189+
tooltipContent: css({
190+
title: 'tooltipContent',
191+
fontSize: theme.typography.bodySmall.fontSize,
192+
width: '100%',
193+
}),
194+
tooltipName: css({
195+
title: 'tooltipName',
196+
marginTop: 0,
197+
wordBreak: 'break-all',
198+
}),
199+
lastParagraph: css({
200+
title: 'lastParagraph',
201+
marginBottom: 0,
202+
}),
203+
name: css({
204+
title: 'name',
205+
marginBottom: '10px',
206+
}),
207+
208+
tooltipTable: css({
209+
title: 'tooltipTable',
210+
maxWidth: '400px',
211+
}),
212212
});
213213

214214
export default FlameGraphTooltip;

0 commit comments

Comments
 (0)