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

77 lines
1.7 KiB
TypeScript
Raw Normal View History

2025-11-11 07:50:11 -08:00
/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
import { Box, type DOMElement } from 'ink';
2025-11-11 07:50:11 -08:00
import { theme } from '../semantic-colors.js';
export interface StickyHeaderProps {
children: React.ReactNode;
width: number;
isFirst: boolean;
borderColor: string;
borderDimColor: boolean;
containerRef?: React.RefObject<DOMElement | null>;
2025-11-11 07:50:11 -08:00
}
export const StickyHeader: React.FC<StickyHeaderProps> = ({
children,
width,
isFirst,
borderColor,
borderDimColor,
containerRef,
2025-11-11 07:50:11 -08:00
}) => (
<Box
ref={containerRef}
2025-11-11 07:50:11 -08:00
sticky
minHeight={1}
flexShrink={0}
width={width}
stickyChildren={
<Box
borderStyle="round"
flexDirection="column"
2025-11-11 07:50:11 -08:00
width={width}
opaque
borderColor={borderColor}
borderDimColor={borderDimColor}
borderBottom={false}
borderTop={isFirst}
paddingTop={isFirst ? 0 : 1}
2025-11-11 07:50:11 -08:00
>
<Box paddingX={1}>{children}</Box>
{/* Dark border to separate header from content. */}
<Box
width={width - 2}
borderColor={theme.ui.dark}
borderStyle="single"
borderTop={false}
borderBottom={true}
borderLeft={false}
borderRight={false}
></Box>
2025-11-11 07:50:11 -08:00
</Box>
}
>
<Box
borderStyle="round"
width={width}
borderColor={borderColor}
borderDimColor={borderDimColor}
borderBottom={false}
borderTop={isFirst}
borderLeft={true}
borderRight={true}
paddingX={1}
paddingBottom={1}
paddingTop={isFirst ? 0 : 1}
>
2025-11-11 07:50:11 -08:00
{children}
</Box>
</Box>
);