Skip to content

Commit 4370c48

Browse files
committed
integrate with holiday theme. do not show snowfall in short width. stop the animation after user enters a text
1 parent 343b9d8 commit 4370c48

File tree

2 files changed

+16
-14
lines changed

2 files changed

+16
-14
lines changed

packages/cli/src/ui/components/Header.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import { getAsciiArtWidth } from '../utils/textUtils.js';
1919
import { useTerminalSize } from '../hooks/useTerminalSize.js';
2020
import { getTerminalProgram } from '../utils/terminalSetup.js';
2121
import { useSnowfall } from '../hooks/useSnowfall.js';
22-
import { useUIState } from '../contexts/UIStateContext.js';
2322

2423
interface HeaderProps {
2524
customAsciiArt?: string; // For user-defined ASCII art
@@ -49,10 +48,7 @@ export const Header: React.FC<HeaderProps> = ({
4948
}
5049

5150
const artWidth = getAsciiArtWidth(displayTitle);
52-
const { history } = useUIState();
53-
const hasStartedChat = history.some((item) => item.type === 'user');
54-
55-
const snowTitle = useSnowfall(displayTitle, { enabled: !hasStartedChat });
51+
const title = useSnowfall(displayTitle);
5652

5753
return (
5854
<Box
@@ -61,7 +57,7 @@ export const Header: React.FC<HeaderProps> = ({
6157
flexShrink={0}
6258
flexDirection="column"
6359
>
64-
<ThemedGradient>{snowTitle}</ThemedGradient>
60+
<ThemedGradient>{title}</ThemedGradient>
6561
{nightly && (
6662
<Box width="100%" flexDirection="row" justifyContent="flex-end">
6763
<ThemedGradient>v{version}</ThemedGradient>

packages/cli/src/ui/hooks/useSnowfall.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ import { getAsciiArtWidth } from '../utils/textUtils.js';
99
import { debugState } from '../debug.js';
1010
import { themeManager } from '../themes/theme-manager.js';
1111
import { Holiday } from '../themes/holiday.js';
12+
import { useUIState } from '../contexts/UIStateContext.js';
13+
import { useTerminalSize } from './useTerminalSize.js';
14+
import { shortAsciiLogo } from '../components/AsciiArt.js';
1215

1316
interface Snowflake {
1417
x: number;
@@ -58,23 +61,26 @@ const addHolidayTrees = (art: string): string => {
5861
return `\n\n${art}\n${centeredTripleTrees}\n\n`;
5962
};
6063

61-
export const useSnowfall = (
62-
art: string,
63-
options: { enabled?: boolean } = {},
64-
): string => {
64+
export const useSnowfall = (displayTitle: string): string => {
6565
const currentTheme = themeManager.getActiveTheme();
66+
const { columns: terminalWidth } = useTerminalSize();
67+
const { history } = useUIState();
68+
69+
const hasStartedChat = history.some((item) => item.type === 'user');
70+
const widthOfShortLogo = getAsciiArtWidth(shortAsciiLogo);
6671

6772
const enabled =
6873
isHolidaySeason &&
6974
currentTheme.name === Holiday.name &&
70-
(options.enabled ?? true);
75+
terminalWidth >= widthOfShortLogo &&
76+
!hasStartedChat;
7177

7278
const displayArt = useMemo(() => {
7379
if (enabled) {
74-
return addHolidayTrees(art);
80+
return addHolidayTrees(displayTitle);
7581
}
76-
return art;
77-
}, [art, enabled]);
82+
return displayTitle;
83+
}, [displayTitle, enabled]);
7884

7985
const [snowflakes, setSnowflakes] = useState<Snowflake[]>([]);
8086
// We don't need 'frame' state if we just use functional updates for snowflakes,

0 commit comments

Comments
 (0)