refactor: centralize font-size clamps in textLimits.ts

Single source of truth for font-size constraints (text 6–160, sticky
8–96) used by creation defaults, resize-bake, and any future mutation
paths. Replaces scattered hardcoded min/max values.
This commit is contained in:
Hiren Kangad
2026-03-12 23:35:25 +05:30
parent 1ac727ea60
commit 150bb91a27
3 changed files with 28 additions and 3 deletions
+23
View File
@@ -0,0 +1,23 @@
/**
* textLimits — single source of truth for font-size constraints.
*
* Every path that creates, resizes, or mutates fontSize on text/sticky
* items must go through these helpers. This prevents inconsistent
* clamping when ranges are widened later.
*/
// Plain text: generous range for direct manipulation
const TEXT_FONT_MIN = 6;
const TEXT_FONT_MAX = 160;
// Sticky note text: narrower range (card layout breaks at extremes)
const STICKY_FONT_MIN = 8;
const STICKY_FONT_MAX = 96;
export function clampTextFontSize(size: number): number {
return Math.round(Math.min(TEXT_FONT_MAX, Math.max(TEXT_FONT_MIN, size)));
}
export function clampStickyFontSize(size: number): number {
return Math.round(Math.min(STICKY_FONT_MAX, Math.max(STICKY_FONT_MIN, size)));
}