Initial Commit

This commit is contained in:
2026-01-29 07:13:33 +00:00
commit 399e93f714
34 changed files with 7663 additions and 0 deletions

113
src/tui/theme.ts Normal file
View File

@@ -0,0 +1,113 @@
/**
* Theme configuration for the CLI TUI using Ink.
* Defines colors, styles, and visual constants used throughout the application.
*/
import type { TextProps } from 'ink';
/**
* Color type - supports Ink color names.
*/
export type Color = TextProps['color'];
/**
* Color palette for the application.
* All colors are compatible with Ink's Text component.
*/
export const colors = {
// Primary colors
primary: 'cyan' as Color,
secondary: 'blue' as Color,
accent: 'magenta' as Color,
// Status colors
success: 'green' as Color,
warning: 'yellow' as Color,
error: 'red' as Color,
info: 'cyan' as Color,
// Text colors
text: 'white' as Color,
textMuted: 'gray' as Color,
textHighlight: 'whiteBright' as Color,
// Background colors
bg: 'black' as Color,
bgSelected: 'blue' as Color,
bgHover: 'gray' as Color,
// Border colors
border: 'cyan' as Color,
borderFocused: 'yellowBright' as Color,
borderMuted: 'gray' as Color,
// Focus highlight color (very visible)
focus: 'yellowBright' as Color,
} as const;
/**
* Layout constants for consistent spacing.
*/
export const layout = {
padding: {
small: 1,
medium: 2,
large: 3,
},
margin: {
small: 1,
medium: 2,
large: 3,
},
} as const;
/**
* ASCII art logo for the application header.
*/
export const logo = `
██╗ ██╗ ██████╗ ██╗ ██╗ █████╗ ██╗ ██╗ ███████╗████████╗
╚██╗██╔╝██╔═══██╗ ██║ ██║██╔══██╗██║ ██║ ██╔════╝╚══██╔══╝
╚███╔╝ ██║ ██║ ██║ █╗ ██║███████║██║ ██║ █████╗ ██║
██╔██╗ ██║ ██║ ██║███╗██║██╔══██║██║ ██║ ██╔══╝ ██║
██╔╝ ██╗╚██████╔╝ ╚███╔███╔╝██║ ██║███████╗███████╗███████╗ ██║
╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═╝╚══════╝╚══════╝╚══════╝ ╚═╝
`.trim();
/**
* Small logo for status bar.
*/
export const logoSmall = 'XO Wallet';
/**
* Helper to format satoshis for display.
* @param satoshis - Amount in satoshis
* @returns Formatted string with BCH amount
*/
export function formatSatoshis(satoshis: bigint | number): string {
const value = typeof satoshis === 'bigint' ? satoshis : BigInt(satoshis);
const bch = Number(value) / 100_000_000;
return `${bch.toFixed(8)} BCH (${value.toLocaleString()} sats)`;
}
/**
* Helper to truncate long strings with ellipsis.
* @param str - String to truncate
* @param maxLength - Maximum length
* @returns Truncated string
*/
export function truncate(str: string, maxLength: number): string {
if (str.length <= maxLength) return str;
return str.slice(0, maxLength - 3) + '...';
}
/**
* Helper to format a hex string for display.
* @param hex - Hex string
* @param maxLength - Maximum display length
* @returns Formatted hex string
*/
export function formatHex(hex: string, maxLength: number = 16): string {
if (hex.length <= maxLength) return hex;
const half = Math.floor((maxLength - 3) / 2);
return `${hex.slice(0, half)}...${hex.slice(-half)}`;
}