refactor: extract magic constants — wave 1 (UX, API, storage)

- Use existing MULTIPLIER_S/M/L from \$entities/Font in SliderArea instead
  of inlining the 0.5/0.75/1 literals (constants already existed but were
  duplicated at the call site).
- Centralize API base URL in \$shared/api/endpoints.ts (was duplicated
  between proxyFonts and FilterAndSortFonts filters api).
- Promote every 'glyphdiff:...' localStorage key to a named module-level
  STORAGE_KEY constant. Test files now import the source constant rather
  than redeclaring it (eliminates silent-typo divergence risk).
This commit is contained in:
Ilia Mashkov
2026-05-24 20:30:26 +03:00
parent f92577608a
commit e3b489f173
10 changed files with 55 additions and 16 deletions
@@ -42,8 +42,10 @@ interface ComparisonState {
export type Side = 'A' | 'B';
const STORAGE_KEY = 'glyphdiff:comparison';
// Persistent storage for selected comparison fonts
const storage = createPersistentStore<ComparisonState>('glyphdiff:comparison', {
const storage = createPersistentStore<ComparisonState>(STORAGE_KEY, {
fontAId: null,
fontBId: null,
});
@@ -8,6 +8,11 @@
- Performance optimized using offscreen canvas for measurements and transform-based animations.
-->
<script lang="ts">
import {
MULTIPLIER_L,
MULTIPLIER_M,
MULTIPLIER_S,
} from '$entities/Font';
import { TypographyMenu } from '$features/AdjustTypography';
import { typographySettingsStore } from '$features/AdjustTypography/model';
import {
@@ -122,16 +127,16 @@ $effect(() => {
}
switch (true) {
case responsive.isMobile:
typography.multiplier = 0.5;
typography.multiplier = MULTIPLIER_S;
break;
case responsive.isTablet:
typography.multiplier = 0.75;
typography.multiplier = MULTIPLIER_M;
break;
case responsive.isDesktop:
typography.multiplier = 1;
typography.multiplier = MULTIPLIER_L;
break;
default:
typography.multiplier = 1;
typography.multiplier = MULTIPLIER_L;
}
});