mirror of
https://github.com/tiennm99/ccs.git
synced 2026-07-17 10:17:05 +00:00
- 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
59 lines
1.4 KiB
TypeScript
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;
|
|
}
|