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

49 lines
1.2 KiB
TypeScript
Raw Normal View History

/**
* @license
* Copyright 2025 Google LLC
* SPDX-License-Identifier: Apache-2.0
*/
import type React from 'react';
2025-04-15 21:41:08 -07:00
import { Text, Box } from 'ink';
2025-09-10 10:57:07 -07:00
import { theme } from '../../semantic-colors.js';
import { RenderInline } from '../../utils/InlineMarkdownRenderer.js';
2025-04-15 21:41:08 -07:00
interface InfoMessageProps {
2025-04-17 18:06:21 -04:00
text: string;
secondaryText?: string;
icon?: string;
color?: string;
marginBottom?: number;
2025-04-15 21:41:08 -07:00
}
export const InfoMessage: React.FC<InfoMessageProps> = ({
text,
secondaryText,
icon,
color,
marginBottom,
}) => {
color ??= theme.status.warning;
const prefix = icon ?? ' ';
2025-04-17 18:06:21 -04:00
const prefixWidth = prefix.length;
2025-04-15 21:41:08 -07:00
2025-04-17 18:06:21 -04:00
return (
<Box flexDirection="row" marginTop={1} marginBottom={marginBottom ?? 0}>
2025-04-17 18:06:21 -04:00
<Box width={prefixWidth}>
<Text color={color}>{prefix}</Text>
2025-04-17 18:06:21 -04:00
</Box>
<Box flexGrow={1} flexDirection="column">
{text.split('\n').map((line, index) => (
<Text wrap="wrap" key={index}>
<RenderInline text={line} defaultColor={color} />
{index === text.split('\n').length - 1 && secondaryText && (
<Text color={theme.text.secondary}> {secondaryText}</Text>
)}
</Text>
))}
2025-04-17 18:06:21 -04:00
</Box>
</Box>
);
2025-04-15 21:41:08 -07:00
};