Files
ccs/src/utils/ui/text.ts
T
kaitranntt c1e5ec70b5 refactor(utils): modularize ui.ts into ui/ directory
- split 647-line ui.ts into 10 focused modules (<115 lines each)

- extract: colors, indicators, boxes, tables, text, spinner, tasks

- add init.ts for shared state and types.ts for interfaces

- ui.ts now re-exports from ui/index.ts for backward compat
2025-12-19 16:01:50 -05:00

59 lines
1.4 KiB
TypeScript

/**
* Text Formatting
*
* Headers, subheaders, and text utilities
* @module utils/ui/text
*/
import { moduleCache, COLORS } from './types';
import { useColors } from './init';
import { gradientText, bold, dim } from './colors';
/**
* Print section header with optional gradient
*/
export function header(text: string, useGradient = true): string {
if (useGradient && useColors()) {
return gradientText(text);
}
return bold(text);
}
/**
* Print subsection header
*/
export function subheader(text: string): string {
if (!moduleCache.chalk || !useColors()) return text;
return moduleCache.chalk.hex(COLORS.primary)(text);
}
/**
* Print horizontal rule
*/
export function hr(char = '─', width = 60): string {
if (!useColors()) {
return '-'.repeat(width);
}
return dim(char.repeat(width));
}
/**
* Print section header with ═══ borders
* Format: ═══ Title ═══
*/
export function sectionHeader(title: string): string {
const border = '═══';
const headerText = `${border} ${title} ${border}`;
// Use gradient + bold for visual appeal
if (moduleCache.gradient && moduleCache.chalk && useColors()) {
return moduleCache.chalk.bold(
moduleCache.gradient([COLORS.primary, COLORS.secondary])(headerText)
);
}
// Fallback to bold primary color
if (useColors() && moduleCache.chalk) {
return moduleCache.chalk.hex(COLORS.primary).bold(headerText);
}
return headerText;
}