From db08f523f696a48f227e08e47cd77fc0e62d70cb Mon Sep 17 00:00:00 2001 From: Ilia Mashkov Date: Thu, 16 Apr 2026 09:05:34 +0300 Subject: [PATCH] chore: move typography constants to the entity/Font layer --- .../Font}/model/const/const.ts | 0 src/entities/Font/model/index.ts | 1 + .../ui/FontApplicator/FontApplicator.svelte | 3 +- src/features/SetupFont/index.ts | 30 +++---------------- .../settingsManager/settingsManager.svelte.ts | 14 ++++----- .../settingsManager/settingsManager.test.ts | 14 ++++----- src/features/SetupFont/model/index.ts | 20 ------------- .../model/state/typographySettingsStore.ts | 2 +- .../ui/TypographyMenu/TypographyMenu.svelte | 12 ++++---- .../ui/FontList/FontList.svelte | 3 +- 10 files changed, 30 insertions(+), 69 deletions(-) rename src/{features/SetupFont => entities/Font}/model/const/const.ts (100%) diff --git a/src/features/SetupFont/model/const/const.ts b/src/entities/Font/model/const/const.ts similarity index 100% rename from src/features/SetupFont/model/const/const.ts rename to src/entities/Font/model/const/const.ts diff --git a/src/entities/Font/model/index.ts b/src/entities/Font/model/index.ts index e353b14..8749b29 100644 --- a/src/entities/Font/model/index.ts +++ b/src/entities/Font/model/index.ts @@ -1,2 +1,3 @@ +export * from './const/const'; export * from './store'; export * from './types'; diff --git a/src/entities/Font/ui/FontApplicator/FontApplicator.svelte b/src/entities/Font/ui/FontApplicator/FontApplicator.svelte index 8482e49..3fbfa9a 100644 --- a/src/entities/Font/ui/FontApplicator/FontApplicator.svelte +++ b/src/entities/Font/ui/FontApplicator/FontApplicator.svelte @@ -10,6 +10,7 @@ import { cn } from '$shared/shadcn/utils/shadcn-utils'; import type { Snippet } from 'svelte'; import { prefersReducedMotion } from 'svelte/motion'; import { + DEFAULT_FONT_WEIGHT, type UnifiedFont, appliedFontsManager, } from '../../model'; @@ -36,7 +37,7 @@ interface Props { let { font, - weight = 400, + weight = DEFAULT_FONT_WEIGHT, className, children, }: Props = $props(); diff --git a/src/features/SetupFont/index.ts b/src/features/SetupFont/index.ts index d712fd0..c48f481 100644 --- a/src/features/SetupFont/index.ts +++ b/src/features/SetupFont/index.ts @@ -1,28 +1,6 @@ -export { TypographyMenu } from './ui'; - export { - type ControlId, - controlManager, - DEFAULT_FONT_SIZE, - DEFAULT_FONT_WEIGHT, - DEFAULT_LETTER_SPACING, - DEFAULT_LINE_HEIGHT, - DEFAULT_TYPOGRAPHY_CONTROLS_DATA, - FONT_SIZE_STEP, - FONT_WEIGHT_STEP, - LINE_HEIGHT_STEP, - MAX_FONT_SIZE, - MAX_FONT_WEIGHT, - MAX_LINE_HEIGHT, - MIN_FONT_SIZE, - MIN_FONT_WEIGHT, - MIN_LINE_HEIGHT, - MULTIPLIER_L, - MULTIPLIER_M, - MULTIPLIER_S, -} from './model'; - -export { - createTypographyControlManager, - type TypographyControlManager, + createTypographySettingsManager, + type TypographySettingsManager, } from './lib'; +export { typographySettingsStore } from './model'; +export { TypographyMenu } from './ui'; diff --git a/src/features/SetupFont/lib/settingsManager/settingsManager.svelte.ts b/src/features/SetupFont/lib/settingsManager/settingsManager.svelte.ts index a3c9414..50accf6 100644 --- a/src/features/SetupFont/lib/settingsManager/settingsManager.svelte.ts +++ b/src/features/SetupFont/lib/settingsManager/settingsManager.svelte.ts @@ -10,6 +10,12 @@ * when displaying/editing, but the base size is what's stored. */ +import { + DEFAULT_FONT_SIZE, + DEFAULT_FONT_WEIGHT, + DEFAULT_LETTER_SPACING, + DEFAULT_LINE_HEIGHT, +} from '$entities/Font'; import { type ControlDataModel, type ControlModel, @@ -19,13 +25,7 @@ import { createTypographyControl, } from '$shared/lib'; import { SvelteMap } from 'svelte/reactivity'; -import { - type ControlId, - DEFAULT_FONT_SIZE, - DEFAULT_FONT_WEIGHT, - DEFAULT_LETTER_SPACING, - DEFAULT_LINE_HEIGHT, -} from '../../model'; +import { type ControlId } from '../../model'; type ControlOnlyFields = Omit, keyof ControlDataModel>; diff --git a/src/features/SetupFont/lib/settingsManager/settingsManager.test.ts b/src/features/SetupFont/lib/settingsManager/settingsManager.test.ts index a50cdb7..3f66536 100644 --- a/src/features/SetupFont/lib/settingsManager/settingsManager.test.ts +++ b/src/features/SetupFont/lib/settingsManager/settingsManager.test.ts @@ -1,4 +1,11 @@ /** @vitest-environment jsdom */ +import { + DEFAULT_FONT_SIZE, + DEFAULT_FONT_WEIGHT, + DEFAULT_LETTER_SPACING, + DEFAULT_LINE_HEIGHT, + DEFAULT_TYPOGRAPHY_CONTROLS_DATA, +} from '$entities/Font'; import { afterEach, beforeEach, @@ -7,13 +14,6 @@ import { it, vi, } from 'vitest'; -import { - DEFAULT_FONT_SIZE, - DEFAULT_FONT_WEIGHT, - DEFAULT_LETTER_SPACING, - DEFAULT_LINE_HEIGHT, - DEFAULT_TYPOGRAPHY_CONTROLS_DATA, -} from '../../model'; import { type TypographySettings, TypographySettingsManager, diff --git a/src/features/SetupFont/model/index.ts b/src/features/SetupFont/model/index.ts index 2e7f5e0..7497623 100644 --- a/src/features/SetupFont/model/index.ts +++ b/src/features/SetupFont/model/index.ts @@ -1,23 +1,3 @@ -export { - DEFAULT_FONT_SIZE, - DEFAULT_FONT_WEIGHT, - DEFAULT_LETTER_SPACING, - DEFAULT_LINE_HEIGHT, - DEFAULT_TYPOGRAPHY_CONTROLS_DATA, - FONT_SIZE_STEP, - FONT_WEIGHT_STEP, - LINE_HEIGHT_STEP, - MAX_FONT_SIZE, - MAX_FONT_WEIGHT, - MAX_LINE_HEIGHT, - MIN_FONT_SIZE, - MIN_FONT_WEIGHT, - MIN_LINE_HEIGHT, - MULTIPLIER_L, - MULTIPLIER_M, - MULTIPLIER_S, -} from './const/const'; - export { type ControlId, typographySettingsStore, diff --git a/src/features/SetupFont/model/state/typographySettingsStore.ts b/src/features/SetupFont/model/state/typographySettingsStore.ts index 65d6fb1..bb377a6 100644 --- a/src/features/SetupFont/model/state/typographySettingsStore.ts +++ b/src/features/SetupFont/model/state/typographySettingsStore.ts @@ -1,5 +1,5 @@ +import { DEFAULT_TYPOGRAPHY_CONTROLS_DATA } from '$entities/Font'; import { createTypographySettingsManager } from '../../lib'; -import { DEFAULT_TYPOGRAPHY_CONTROLS_DATA } from '../const/const'; export type ControlId = 'font_size' | 'font_weight' | 'line_height' | 'letter_spacing'; export const typographySettingsStore = createTypographySettingsManager( diff --git a/src/features/SetupFont/ui/TypographyMenu/TypographyMenu.svelte b/src/features/SetupFont/ui/TypographyMenu/TypographyMenu.svelte index e4e864c..856d7d8 100644 --- a/src/features/SetupFont/ui/TypographyMenu/TypographyMenu.svelte +++ b/src/features/SetupFont/ui/TypographyMenu/TypographyMenu.svelte @@ -6,6 +6,11 @@ Desktop: inline bar with combo controls. -->