Files
gemini-cli/packages/cli/src/ui/components/Header.tsx

60 lines
1.6 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
import { Box } from 'ink';
import { ThemedGradient } from './ThemedGradient.js';
import { shortAsciiLogo, longAsciiLogo, tinyAsciiLogo } from './AsciiArt.js';
2025-06-13 00:59:45 -07:00
import { getAsciiArtWidth } from '../utils/textUtils.js';
import { useTerminalSize } from '../hooks/useTerminalSize.js';
import { useSnowfall } from '../hooks/useSnowfall.js';
2025-06-05 18:14:02 -07:00
interface HeaderProps {
2025-06-13 00:59:45 -07:00
customAsciiArt?: string; // For user-defined ASCII art
version: string;
nightly: boolean;
2025-06-05 18:14:02 -07:00
}
2025-06-13 00:59:45 -07:00
export const Header: React.FC<HeaderProps> = ({
customAsciiArt,
version,
nightly,
2025-06-13 00:59:45 -07:00
}) => {
const { columns: terminalWidth } = useTerminalSize();
2025-06-13 00:59:45 -07:00
let displayTitle;
const widthOfLongLogo = getAsciiArtWidth(longAsciiLogo);
const widthOfShortLogo = getAsciiArtWidth(shortAsciiLogo);
2025-06-13 00:59:45 -07:00
if (customAsciiArt) {
displayTitle = customAsciiArt;
} else if (terminalWidth >= widthOfLongLogo) {
displayTitle = longAsciiLogo;
} else if (terminalWidth >= widthOfShortLogo) {
displayTitle = shortAsciiLogo;
2025-06-13 00:59:45 -07:00
} else {
displayTitle = tinyAsciiLogo;
2025-06-13 00:59:45 -07:00
}
2025-06-23 23:43:17 +00:00
const artWidth = getAsciiArtWidth(displayTitle);
const title = useSnowfall(displayTitle);
2025-06-23 23:43:17 +00:00
2025-06-13 00:59:45 -07:00
return (
2025-06-23 23:43:17 +00:00
<Box
alignItems="flex-start"
width={artWidth}
flexShrink={0}
flexDirection="column"
2025-06-23 23:43:17 +00:00
>
<ThemedGradient>{title}</ThemedGradient>
{nightly && (
<Box width="100%" flexDirection="row" justifyContent="flex-end">
<ThemedGradient>v{version}</ThemedGradient>
</Box>
)}
2025-06-23 23:43:17 +00:00
</Box>
2025-06-13 00:59:45 -07:00
);
};