/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import React from 'react'; import { Box, Text } from 'ink'; import Gradient from 'ink-gradient'; import { theme } from '../semantic-colors.js'; import { shortAsciiLogo, longAsciiLogo, tinyAsciiLogo } from './AsciiArt.js'; import { getAsciiArtWidth } from '../utils/textUtils.js'; import { useTerminalSize } from '../hooks/useTerminalSize.js'; interface HeaderProps { customAsciiArt?: string; // For user-defined ASCII art version: string; nightly: boolean; } const GradientText: React.FC<{ children: React.ReactNode }> = ({ children, }) => { const textElement = {children}; if (theme.ui.gradient && theme.ui.gradient.length > 0) { return {textElement}; } return textElement; }; export const Header: React.FC = ({ customAsciiArt, version, nightly, }) => { const { columns: terminalWidth } = useTerminalSize(); let displayTitle; const widthOfLongLogo = getAsciiArtWidth(longAsciiLogo); const widthOfShortLogo = getAsciiArtWidth(shortAsciiLogo); if (customAsciiArt) { displayTitle = customAsciiArt; } else if (terminalWidth >= widthOfLongLogo) { displayTitle = longAsciiLogo; } else if (terminalWidth >= widthOfShortLogo) { displayTitle = shortAsciiLogo; } else { displayTitle = tinyAsciiLogo; } const artWidth = getAsciiArtWidth(displayTitle); return ( {displayTitle} {nightly && ( v{version} )} ); };