2026-02-06 11:33:39 -08:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import type React from 'react';
|
2026-02-06 22:35:14 -08:00
|
|
|
import { Box } from 'ink';
|
2026-02-06 11:33:39 -08:00
|
|
|
import { theme } from '../../semantic-colors.js';
|
|
|
|
|
|
2026-02-09 23:05:54 -08:00
|
|
|
export type LinePosition = 'top' | 'center' | 'bottom';
|
|
|
|
|
|
2026-02-06 11:33:39 -08:00
|
|
|
interface HorizontalLineProps {
|
|
|
|
|
color?: string;
|
2026-02-09 23:05:54 -08:00
|
|
|
width?: number | string;
|
|
|
|
|
position?: LinePosition;
|
2026-02-06 11:33:39 -08:00
|
|
|
}
|
|
|
|
|
|
2026-02-09 23:05:54 -08:00
|
|
|
const overlineStyle = {
|
|
|
|
|
top: '‾',
|
|
|
|
|
bottom: '',
|
|
|
|
|
left: '',
|
|
|
|
|
right: '',
|
|
|
|
|
topLeft: '',
|
|
|
|
|
topRight: '',
|
|
|
|
|
bottomLeft: '',
|
|
|
|
|
bottomRight: '',
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const underlineStyle = {
|
|
|
|
|
top: '_',
|
|
|
|
|
bottom: '',
|
|
|
|
|
left: '',
|
|
|
|
|
right: '',
|
|
|
|
|
topLeft: '',
|
|
|
|
|
topRight: '',
|
|
|
|
|
bottomLeft: '',
|
|
|
|
|
bottomRight: '',
|
|
|
|
|
};
|
|
|
|
|
|
2026-02-06 11:33:39 -08:00
|
|
|
export const HorizontalLine: React.FC<HorizontalLineProps> = ({
|
|
|
|
|
color = theme.border.default,
|
2026-02-09 23:05:54 -08:00
|
|
|
width = '100%',
|
|
|
|
|
position = 'center',
|
|
|
|
|
}) => {
|
|
|
|
|
const borderStyle =
|
|
|
|
|
position === 'top'
|
|
|
|
|
? overlineStyle
|
|
|
|
|
: position === 'bottom'
|
|
|
|
|
? underlineStyle
|
|
|
|
|
: 'single';
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Box
|
|
|
|
|
width={width}
|
|
|
|
|
borderStyle={borderStyle}
|
|
|
|
|
borderTop
|
|
|
|
|
borderBottom={false}
|
|
|
|
|
borderLeft={false}
|
|
|
|
|
borderRight={false}
|
|
|
|
|
borderColor={color}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
};
|