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

52 lines
1.2 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
2025-04-15 21:41:08 -07:00
import React from 'react';
2025-06-05 00:00:34 -07:00
import { Box, Text } from 'ink';
2025-04-19 12:38:09 -04:00
import Gradient from 'ink-gradient';
2025-04-24 11:56:23 -07:00
import { Colors } from '../colors.js';
2025-06-13 00:59:45 -07:00
import { shortAsciiLogo, longAsciiLogo } from './AsciiArt.js';
import { getAsciiArtWidth } from '../utils/textUtils.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
terminalWidth: number; // For responsive logo
2025-06-05 18:14:02 -07:00
}
2025-06-13 00:59:45 -07:00
export const Header: React.FC<HeaderProps> = ({
customAsciiArt,
terminalWidth,
}) => {
let displayTitle;
const widthOfLongLogo = getAsciiArtWidth(longAsciiLogo);
if (customAsciiArt) {
displayTitle = customAsciiArt;
} else {
displayTitle =
terminalWidth >= widthOfLongLogo ? longAsciiLogo : shortAsciiLogo;
}
2025-06-23 23:43:17 +00:00
const artWidth = getAsciiArtWidth(displayTitle);
2025-06-13 00:59:45 -07:00
return (
2025-06-23 23:43:17 +00:00
<Box
marginBottom={1}
alignItems="flex-start"
width={artWidth}
flexShrink={0}
>
{Colors.GradientColors ? (
<Gradient colors={Colors.GradientColors}>
2025-06-13 00:59:45 -07:00
<Text>{displayTitle}</Text>
2025-06-23 23:43:17 +00:00
</Gradient>
) : (
<Text>{displayTitle}</Text>
)}
</Box>
2025-06-13 00:59:45 -07:00
);
};