Split speed graph and value into separate modules
Render the 150-pixel sparkline and fixed-width speed label as independent bordered pills so changing digit counts cannot move or resize the graph.
This commit is contained in:
@@ -1403,7 +1403,9 @@ const DownloadSpeedSparkline = memo(function DownloadSpeedSparkline({ speedBps,
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={`speed-sparkline${hidden ? " speed-sparkline-hidden" : ""}`} aria-hidden={hidden} title="Aktuelle Download-Geschwindigkeit (geglättet)">
|
<div className={`speed-sparkline${hidden ? " speed-sparkline-hidden" : ""}`} aria-hidden={hidden} title="Aktuelle Download-Geschwindigkeit (geglättet)">
|
||||||
<canvas ref={canvasRef} className="speed-sparkline-canvas" />
|
<div className="speed-sparkline-graph">
|
||||||
|
<canvas ref={canvasRef} className="speed-sparkline-canvas" />
|
||||||
|
</div>
|
||||||
<span className="speed-sparkline-value">{speedBps > 0 ? formatSpeedMbps(speedBps) : "0 B/s"}</span>
|
<span className="speed-sparkline-value">{speedBps > 0 ? formatSpeedMbps(speedBps) : "0 B/s"}</span>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
+17
-2
@@ -609,12 +609,17 @@ body,
|
|||||||
.speed-sparkline {
|
.speed-sparkline {
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
gap: 8px;
|
gap: 6px;
|
||||||
height: 30px;
|
height: 30px;
|
||||||
padding: 0 10px;
|
}
|
||||||
|
|
||||||
|
.speed-sparkline-graph,
|
||||||
|
.speed-sparkline-value {
|
||||||
background: var(--field);
|
background: var(--field);
|
||||||
border: 1px solid var(--border);
|
border: 1px solid var(--border);
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
|
box-sizing: content-box;
|
||||||
|
height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.speed-sparkline-hidden {
|
.speed-sparkline-hidden {
|
||||||
@@ -628,10 +633,20 @@ body,
|
|||||||
display: block;
|
display: block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.speed-sparkline-graph {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
padding: 0 10px;
|
||||||
|
}
|
||||||
|
|
||||||
.speed-sparkline-value {
|
.speed-sparkline-value {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: flex-end;
|
||||||
flex: 0 0 12ch;
|
flex: 0 0 12ch;
|
||||||
width: 12ch;
|
width: 12ch;
|
||||||
min-width: 12ch;
|
min-width: 12ch;
|
||||||
|
padding: 0 10px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-variant-numeric: tabular-nums;
|
font-variant-numeric: tabular-nums;
|
||||||
|
|||||||
@@ -595,9 +595,12 @@ describe("bandwidth chart palette", () => {
|
|||||||
|
|
||||||
it("uses the spare zero-speed label space for a longer sparkline", () => {
|
it("uses the spare zero-speed label space for a longer sparkline", () => {
|
||||||
const css = readFileSync(new URL("../src/renderer/styles.css", import.meta.url), "utf8");
|
const css = readFileSync(new URL("../src/renderer/styles.css", import.meta.url), "utf8");
|
||||||
|
const source = readFileSync(new URL("../src/renderer/App.tsx", import.meta.url), "utf8");
|
||||||
|
|
||||||
expect(css).toMatch(/\.speed-sparkline-canvas\s*\{[^}]*width:\s*150px;/s);
|
expect(css).toMatch(/\.speed-sparkline-canvas\s*\{[^}]*width:\s*150px;/s);
|
||||||
expect(css).toMatch(/\.speed-sparkline-value\s*\{[^}]*flex:\s*0 0 12ch;[^}]*width:\s*12ch;[^}]*min-width:\s*12ch;/s);
|
expect(css).toMatch(/\.speed-sparkline-value\s*\{[^}]*flex:\s*0 0 12ch;[^}]*width:\s*12ch;[^}]*min-width:\s*12ch;/s);
|
||||||
|
expect(source).toContain('className="speed-sparkline-graph"');
|
||||||
|
expect(css).toMatch(/\.speed-sparkline-graph,\s*\.speed-sparkline-value\s*\{[^}]*background:\s*var\(--field\);[^}]*border:\s*1px solid var\(--border\);[^}]*border-radius:\s*8px;/s);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("aligns the idle speed line to one physical pixel at every display scale", () => {
|
it("aligns the idle speed line to one physical pixel at every display scale", () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user