refactor(font): split types into separate files for better maintainability
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
import type {
|
||||
FontshareApiModel,
|
||||
FontshareFont,
|
||||
} from '$entities/Font';
|
||||
} from '$entities/Font/model/types/fontshare';
|
||||
import { api } from '$shared/api/api';
|
||||
import { buildQueryString } from '$shared/utils';
|
||||
import type { QueryParams } from '$shared/utils';
|
||||
@@ -43,7 +43,7 @@ export interface FontshareParams extends QueryParams {
|
||||
|
||||
/**
|
||||
* Fontshare API response wrapper
|
||||
* Re-exported from model/types for backward compatibility
|
||||
* Re-exported from model/types/fontshare for backward compatibility
|
||||
*/
|
||||
export type FontshareResponse = FontshareApiModel;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
import type {
|
||||
FontItem,
|
||||
GoogleFontsApiModel,
|
||||
} from '$entities/Font';
|
||||
} from '$entities/Font/model/types/google';
|
||||
import { api } from '$shared/api/api';
|
||||
import { buildQueryString } from '$shared/utils';
|
||||
import type { QueryParams } from '$shared/utils';
|
||||
@@ -47,13 +47,13 @@ export interface GoogleFontsParams extends QueryParams {
|
||||
|
||||
/**
|
||||
* Google Fonts API response wrapper
|
||||
* Re-exported from model/types for backward compatibility
|
||||
* Re-exported from model/types/google for backward compatibility
|
||||
*/
|
||||
export type GoogleFontsResponse = GoogleFontsApiModel;
|
||||
|
||||
/**
|
||||
* Simplified font item from Google Fonts API
|
||||
* Re-exported from model/types for backward compatibility
|
||||
* Re-exported from model/types/google for backward compatibility
|
||||
*/
|
||||
export type GoogleFontItem = FontItem;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type {
|
||||
FontshareFont,
|
||||
GoogleFontItem,
|
||||
UnifiedFont,
|
||||
} from '$entities/Font';
|
||||
} from '$entities/Font/model/types';
|
||||
import {
|
||||
describe,
|
||||
expect,
|
||||
@@ -136,9 +136,9 @@ describe('Font Normalization', () => {
|
||||
});
|
||||
|
||||
it('maps variant weights correctly', () => {
|
||||
const font = {
|
||||
const font: GoogleFontItem = {
|
||||
...mockGoogleFont,
|
||||
variants: ['regular', '100', '400', '700', '900'],
|
||||
variants: ['regular', '100', '400', '700', '900'] as any,
|
||||
};
|
||||
const result = normalizeGoogleFont(font);
|
||||
|
||||
|
||||
@@ -12,10 +12,10 @@ import type {
|
||||
FontProvider,
|
||||
FontStyleUrls,
|
||||
FontSubset,
|
||||
FontshareFont,
|
||||
GoogleFontItem,
|
||||
UnifiedFont,
|
||||
} from '../../model/types';
|
||||
} from '$entities/Font/model/types';
|
||||
import type { FontshareFont } from '$entities/Font/model/types/fontshare';
|
||||
import type { GoogleFontItem } from '$entities/Font/model/types/google';
|
||||
import type { UnifiedFont } from '$entities/Font/model/types/normalize';
|
||||
|
||||
/**
|
||||
* Map Google Fonts category to unified FontCategory
|
||||
@@ -272,3 +272,6 @@ export function normalizeFontshareFonts(
|
||||
): UnifiedFont[] {
|
||||
return apiFonts.map(normalizeFontshareFont);
|
||||
}
|
||||
|
||||
// Re-export UnifiedFont for backward compatibility
|
||||
export type { UnifiedFont } from '$entities/Font/model/types/normalize';
|
||||
|
||||
Reference in New Issue
Block a user