|
| 1 | +import React from 'react'; |
| 2 | +import { View, Text, ViewProps, TextProps } from 'react-native'; |
| 3 | +import { cn } from '../../../lib/utils'; |
| 4 | + |
| 5 | +import { |
| 6 | + cardClassNames, |
| 7 | + cardHeaderClassNames, |
| 8 | + cardTitleClassNames, |
| 9 | + cardDescriptionClassNames, |
| 10 | + cardContentClassNames, |
| 11 | + cardFooterClassNames, |
| 12 | +} from './styles'; |
| 13 | + |
| 14 | +// Main Card container |
| 15 | +interface CardProps extends ViewProps { |
| 16 | + className?: string; |
| 17 | + mode?: 'light' | 'dark'; |
| 18 | +} |
| 19 | + |
| 20 | +const Card = ({ className, mode = 'light', ...props }: CardProps) => { |
| 21 | + return ( |
| 22 | + <View |
| 23 | + className={cn( |
| 24 | + cardClassNames.base, |
| 25 | + cardClassNames[mode].container, |
| 26 | + cardClassNames[mode].text, |
| 27 | + className |
| 28 | + )} |
| 29 | + {...props} |
| 30 | + /> |
| 31 | + ); |
| 32 | +}; |
| 33 | + |
| 34 | +// Card Header |
| 35 | +interface CardHeaderProps extends ViewProps { |
| 36 | + className?: string; |
| 37 | +} |
| 38 | + |
| 39 | +const CardHeader = ({ className, ...props }: CardHeaderProps) => { |
| 40 | + return <View className={cn(cardHeaderClassNames.base, className)} {...props} />; |
| 41 | +}; |
| 42 | + |
| 43 | +// Card Title |
| 44 | +interface CardTitleProps extends TextProps { |
| 45 | + className?: string; |
| 46 | + mode?: 'light' | 'dark'; |
| 47 | +} |
| 48 | + |
| 49 | +const CardTitle = ({ className, mode = 'light', ...props }: CardTitleProps) => { |
| 50 | + return ( |
| 51 | + <Text |
| 52 | + className={cn(cardTitleClassNames.base, cardTitleClassNames[mode], className)} |
| 53 | + {...props} |
| 54 | + /> |
| 55 | + ); |
| 56 | +}; |
| 57 | + |
| 58 | +// Card Description |
| 59 | +interface CardDescriptionProps extends TextProps { |
| 60 | + className?: string; |
| 61 | + mode?: 'light' | 'dark'; |
| 62 | +} |
| 63 | + |
| 64 | +const CardDescription = ({ className, mode = 'light', ...props }: CardDescriptionProps) => { |
| 65 | + return ( |
| 66 | + <Text |
| 67 | + className={cn(cardDescriptionClassNames.base, cardDescriptionClassNames[mode], className)} |
| 68 | + {...props} |
| 69 | + /> |
| 70 | + ); |
| 71 | +}; |
| 72 | + |
| 73 | +// Card Content |
| 74 | +interface CardContentProps extends ViewProps { |
| 75 | + className?: string; |
| 76 | +} |
| 77 | + |
| 78 | +const CardContent = ({ className, ...props }: CardContentProps) => { |
| 79 | + return <View className={cn(cardContentClassNames.base, className)} {...props} />; |
| 80 | +}; |
| 81 | + |
| 82 | +// Card Footer |
| 83 | +interface CardFooterProps extends ViewProps { |
| 84 | + className?: string; |
| 85 | +} |
| 86 | + |
| 87 | +const CardFooter = ({ className, ...props }: CardFooterProps) => { |
| 88 | + return <View className={cn(cardFooterClassNames.base, className)} {...props} />; |
| 89 | +}; |
| 90 | + |
| 91 | +export { Card, CardHeader, CardFooter, CardTitle, CardDescription, CardContent }; |
0 commit comments