2025-04-18 17:44:24 -07:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
2025-08-26 00:04:53 +02:00
|
|
|
import type React from 'react';
|
2025-11-16 20:45:07 -08:00
|
|
|
import { Box } from 'ink';
|
|
|
|
|
import { ThemedGradient } from './ThemedGradient.js';
|
2026-01-29 15:44:02 -05:00
|
|
|
import { shortAsciiLogo, longAsciiLogo, tinyAsciiLogo } from './AsciiArt.js';
|
2025-06-13 00:59:45 -07:00
|
|
|
import { getAsciiArtWidth } from '../utils/textUtils.js';
|
2025-08-07 15:55:53 -07:00
|
|
|
import { useTerminalSize } from '../hooks/useTerminalSize.js';
|
2025-12-26 11:07:39 -05:00
|
|
|
import { useSnowfall } from '../hooks/useSnowfall.js';
|
2025-06-02 17:09:55 -07:00
|
|
|
|
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
|
2025-07-11 13:43:57 -07:00
|
|
|
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,
|
2025-07-11 13:43:57 -07:00
|
|
|
version,
|
|
|
|
|
nightly,
|
2025-06-13 00:59:45 -07:00
|
|
|
}) => {
|
2025-08-07 15:55:53 -07:00
|
|
|
const { columns: terminalWidth } = useTerminalSize();
|
2025-06-13 00:59:45 -07:00
|
|
|
let displayTitle;
|
|
|
|
|
const widthOfLongLogo = getAsciiArtWidth(longAsciiLogo);
|
2025-08-07 15:55:53 -07:00
|
|
|
const widthOfShortLogo = getAsciiArtWidth(shortAsciiLogo);
|
2025-06-13 00:59:45 -07:00
|
|
|
|
|
|
|
|
if (customAsciiArt) {
|
|
|
|
|
displayTitle = customAsciiArt;
|
2025-08-07 15:55:53 -07:00
|
|
|
} else if (terminalWidth >= widthOfLongLogo) {
|
2026-01-29 15:44:02 -05:00
|
|
|
displayTitle = longAsciiLogo;
|
2025-08-07 15:55:53 -07:00
|
|
|
} else if (terminalWidth >= widthOfShortLogo) {
|
2026-01-29 15:44:02 -05:00
|
|
|
displayTitle = shortAsciiLogo;
|
2025-06-13 00:59:45 -07:00
|
|
|
} else {
|
2026-01-29 15:44:02 -05:00
|
|
|
displayTitle = tinyAsciiLogo;
|
2025-06-13 00:59:45 -07:00
|
|
|
}
|
|
|
|
|
|
2025-06-23 23:43:17 +00:00
|
|
|
const artWidth = getAsciiArtWidth(displayTitle);
|
2025-12-26 11:07:39 -05:00
|
|
|
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}
|
2025-07-11 13:43:57 -07:00
|
|
|
flexDirection="column"
|
2025-06-23 23:43:17 +00:00
|
|
|
>
|
2025-12-26 11:07:39 -05:00
|
|
|
<ThemedGradient>{title}</ThemedGradient>
|
2025-07-11 13:43:57 -07:00
|
|
|
{nightly && (
|
|
|
|
|
<Box width="100%" flexDirection="row" justifyContent="flex-end">
|
2025-11-10 19:57:43 -08:00
|
|
|
<ThemedGradient>v{version}</ThemedGradient>
|
2025-07-11 13:43:57 -07:00
|
|
|
</Box>
|
|
|
|
|
)}
|
2025-06-23 23:43:17 +00:00
|
|
|
</Box>
|
2025-06-13 00:59:45 -07:00
|
|
|
);
|
|
|
|
|
};
|