Files
stats/apps/dashboard/src/components/ui/key-value.tsx
Carl-Gerhard Lindesvärd a1fa48da75 dashboard: add dark mode
2024-03-28 06:47:04 +01:00

35 lines
956 B
TypeScript

import { cn } from '@/utils/cn';
import Link from 'next/link';
interface KeyValueProps {
name: string;
value: any;
onClick?: () => void;
href?: string;
}
export function KeyValue({ href, onClick, name, value }: KeyValueProps) {
const clickable = href || onClick;
const Component = (href ? Link : onClick ? 'button' : 'div') as 'button';
return (
<Component
className={cn(
'group flex min-w-0 max-w-full divide-x self-start overflow-hidden rounded-md border border-border text-xs font-medium transition-transform',
clickable && 'hover:-translate-y-0.5'
)}
{...{ href, onClick }}
>
<div className="bg-black/5 p-1 px-2">{name}</div>
<div
className={cn(
'overflow-hidden text-ellipsis whitespace-nowrap bg-background p-1 px-2 font-mono text-blue-700',
clickable && 'group-hover:underline'
)}
>
{value}
</div>
</Component>
);
}