프로필 UI 글자 크기를 네 단계와 공통 축소 규칙으로 통일한다
This commit is contained in:
@@ -65,6 +65,8 @@ const normalizeStructuralTag = (tag: string): string | null => {
|
||||
|
||||
export type FormatLegacyLogHtmlOptions = {
|
||||
colorize?: boolean;
|
||||
/** Game UI can use its shared step-down class; other consumers retain the legacy ratio. */
|
||||
smallText?: 'relative' | 'semantic';
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,7 +90,8 @@ export const formatLegacyLogHtml = (value?: string | null, options: FormatLegacy
|
||||
if (legacy === '/') return '</span>';
|
||||
const colorCode = legacy === '1' ? null : legacy[0]!;
|
||||
const small = legacy === '1' || legacy.endsWith('1');
|
||||
return `<span style="${colorCode ? (legacyStyleMap[colorCode] ?? '') : ''}${small ? legacyStyleMap['1'] : ''}">`;
|
||||
const semanticSmall = small && options.smallText === 'semantic';
|
||||
return `<span${semanticSmall ? ' class="legacy-small"' : ''} style="${colorCode ? (legacyStyleMap[colorCode] ?? '') : ''}${small && !semanticSmall ? legacyStyleMap['1'] : ''}">`;
|
||||
}
|
||||
|
||||
return normalizeStructuralTag(part) ?? escapeText(part);
|
||||
|
||||
@@ -3,6 +3,13 @@ import { describe, expect, it } from 'vitest';
|
||||
import { formatLegacyLogHtml } from '../src/logging/formatLegacyLogHtml.js';
|
||||
|
||||
describe('formatLegacyLogHtml', () => {
|
||||
it('can render semantic small spans without changing the legacy default or color markup', () => {
|
||||
expect(formatLegacyLogHtml('<Y1>작게<1>중첩</></>', { smallText: 'semantic' })).toBe(
|
||||
'<span class="legacy-small" style="color: yellow;">작게<span class="legacy-small" style="">중첩</span></span>'
|
||||
);
|
||||
expect(formatLegacyLogHtml('<Y1>작게</>', { smallText: 'semantic', colorize: false })).toBe('작게');
|
||||
});
|
||||
|
||||
it('converts legacy colors and preserves intentional emphasis and line breaks', () => {
|
||||
expect(formatLegacyLogHtml('<R><b>위험</b></><br><Y1>작게</><1>작게만</>')).toBe(
|
||||
'<span style="color: red;"><b>위험</b></span><br><span style="color: yellow;font-size: 0.9em;">작게</span><span style="font-size: 0.9em;">작게만</span>'
|
||||
|
||||
Reference in New Issue
Block a user