Skip to content

Commit 93a8ec0

Browse files
Copilotmikebarkmin
andcommitted
Extract magic numbers as named constants in fontSizes
- Add named constants for font size thresholds - Improve code maintainability and clarity Co-authored-by: mikebarkmin <2592379+mikebarkmin@users.noreply.github.com>
1 parent 6d3c54c commit 93a8ec0

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

packages/learningmap/src/fontSizes.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@ export const FONT_SIZE_VALUES: Record<FontSizeOption, number> = {
1111

1212
export const DEFAULT_FONT_SIZE: FontSizeOption = "M";
1313

14+
// Thresholds for mapping numeric values to font size options
15+
const THRESHOLD_S_TO_M = 10;
16+
const THRESHOLD_M_TO_L = 14;
17+
const THRESHOLD_L_TO_XL = 18;
18+
1419
// Helper function to map numeric value to closest font size option
1520
function mapNumericToOption(value: number): FontSizeOption {
16-
if (value <= 10) return "S";
17-
if (value <= 14) return "M";
18-
if (value <= 18) return "L";
21+
if (value <= THRESHOLD_S_TO_M) return "S";
22+
if (value <= THRESHOLD_M_TO_L) return "M";
23+
if (value <= THRESHOLD_L_TO_XL) return "L";
1924
return "XL";
2025
}
2126

0 commit comments

Comments
 (0)