Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

1.2 KB
Raw Blame
import { ReactNode } from 'react';
import { Button } from '@signozhq/ui/button';
import { X } from '@signozhq/icons';

import './DetailsHeader.styles.scss';

export interface HeaderAction {
	key: string;
	component: ReactNode; // check later if we can use direct btn itself or not.
}

export interface DetailsHeaderProps {
	title: string;
	onClose: () => void;
	actions?: HeaderAction[];
	closePosition?: 'left' | 'right';
	className?: string;
}

function DetailsHeader({
	title,
	onClose,
	actions,
	closePosition = 'right',
	className,
}: DetailsHeaderProps): JSX.Element {
	const closeButton = (
		<Button
			variant="ghost"
			size="sm"
			icon
			color="secondary"
			onClick={onClose}
			aria-label="Close"
		>
			<X size={14} />
		</Button>
	);

	return (
		<div className={`details-header ${className || ''}`}>
			{closePosition === 'left' && closeButton}

			<span className="details-header__title">{title}</span>

			{actions && (
				<div className="details-header__actions">
					{actions.map((action) => (
						<div key={action.key}>{action.component}</div>
					))}
				</div>
			)}

			{closePosition === 'right' && closeButton}
		</div>
	);
}

export default DetailsHeader;