Files
ewa-ui/src/components/Card.tsx
T
Kaloyan Danchev cdc8829ce7 Initial commit: @ampeco/ewa-ui v1.0.0
Shared React component library with Tailwind plugin for AMPECO EWAs.
8 components: Button, Card, Input, StatusBadge, Loader, EmptyState, Toast, BottomSheet.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-18 19:34:11 +02:00

42 lines
1.0 KiB
TypeScript

import React from 'react';
export interface CardProps {
className?: string;
onClick?: () => void;
children: React.ReactNode;
}
export function Card({ className = '', onClick, children }: CardProps) {
const isInteractive = typeof onClick === 'function';
const classes = [
'bg-surface-elevation-1 rounded-m p-l',
'shadow-[0_1px_3px_rgba(0,0,0,0.1)]',
isInteractive
? 'cursor-pointer hover:scale-[1.01] active:scale-[0.99] transition-transform duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-[var(--btn-primary-bg)] focus-visible:ring-offset-2'
: '',
className,
].filter(Boolean).join(' ');
if (isInteractive) {
return (
<div
role="button"
tabIndex={0}
className={classes}
onClick={onClick}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
e.preventDefault();
onClick();
}
}}
>
{children}
</div>
);
}
return <div className={classes}>{children}</div>;
}