Skip to content

Commit d079682

Browse files
committed
Fix
1 parent 9619452 commit d079682

File tree

2 files changed

+25
-10
lines changed

2 files changed

+25
-10
lines changed

package-lock.json

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cells/src/cells/range-cell.tsx

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,20 @@ import {
99
import * as React from "react";
1010
import { roundedRect } from "../draw-fns.js";
1111

12+
function adaptFontSize(font: string, percentage: number): string {
13+
const regex = /(\d+\.?\d*)\s*(px|rem|em|%|pt)/;
14+
const match = font.match(regex);
15+
16+
if (match) {
17+
const value = parseFloat(match[1]);
18+
const unit = match[2];
19+
const scaledValue = value * percentage;
20+
return font.replace(regex, `${Number(scaledValue.toPrecision(3))}${unit}`);
21+
}
22+
23+
return font;
24+
}
25+
1226
interface RangeCellProps {
1327
readonly kind: "range-cell";
1428
readonly value: number;
@@ -43,7 +57,8 @@ const renderer: CustomRenderer<RangeCell> = {
4357

4458
const rangeSize = max - min;
4559
const fillRatio = (value - min) / rangeSize;
46-
const labelFont = `calc(${theme.baseFontStyle} * 0.9) ${theme.fontFamily}`;
60+
// Only use 90% of the base font size for the label
61+
const labelFont = `${adaptFontSize(theme.baseFontStyle, 0.9)} ${theme.fontFamily}`;
4762

4863
const emHeight = getEmHeight(ctx, labelFont);
4964
const rangeHeight = emHeight / 2;

0 commit comments

Comments
 (0)