managarten/apps/picture/packages/mobile-ui/components/ui/Card/Card.tsx
Wuesteon d36b321d9d style: auto-format codebase with Prettier
Applied formatting to 1487+ files using pnpm format:write
  - TypeScript/JavaScript files
  - Svelte components
  - Astro pages
  - JSON configs
  - Markdown docs

  13 files still need manual review (Astro JSX comments)
2025-11-27 18:33:16 +01:00

80 lines
1.5 KiB
TypeScript

import { View, Pressable, ViewStyle } from 'react-native';
export type CardProps = {
/** Card content */
children: React.ReactNode;
/** Make card pressable */
onPress?: () => void;
/** Background color */
backgroundColor?: string;
/** Border radius */
borderRadius?: number;
/** Padding inside card */
padding?: number;
/** Add shadow */
shadow?: boolean;
/** Add border */
border?: boolean;
/** Border color */
borderColor?: string;
/** Additional styles */
style?: ViewStyle;
};
/**
* Container card component with optional press interaction.
*
* @example
* ```tsx
* <Card>
* <Text variant="h3">Card Title</Text>
* <Text>Card content goes here</Text>
* </Card>
*
* <Card onPress={() => {}} shadow>
* <Text>Pressable card</Text>
* </Card>
* ```
*/
export function Card({
children,
onPress,
backgroundColor = '#FFFFFF',
borderRadius = 12,
padding = 16,
shadow = true,
border = false,
borderColor = '#E5E7EB',
style,
}: CardProps) {
const cardStyles: ViewStyle = {
backgroundColor,
borderRadius,
padding,
...(border && {
borderWidth: 1,
borderColor,
}),
...(shadow && {
shadowColor: '#000',
shadowOffset: { width: 0, height: 2 },
shadowOpacity: 0.1,
shadowRadius: 8,
elevation: 3,
}),
...style,
};
if (onPress) {
return (
<Pressable
onPress={onPress}
style={({ pressed }) => [cardStyles, pressed && { opacity: 0.8 }]}
>
{children}
</Pressable>
);
}
return <View style={cardStyles}>{children}</View>;
}