Skip to content

Commit 867d7b4

Browse files
committed
card docs added to docs site
1 parent b893b16 commit 867d7b4

File tree

4 files changed

+411
-1
lines changed

4 files changed

+411
-1
lines changed

docs/components/ui/card/index.tsx

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
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 };

docs/components/ui/card/styles.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
export const cardClassNames = {
2+
base: 'flex flex-col gap-6 rounded-xl border py-6 shadow-sm',
3+
light: {
4+
container: 'bg-card border-border',
5+
text: 'text-card-foreground',
6+
},
7+
dark: {
8+
container: 'bg-dark-card border-dark-border',
9+
text: 'text-dark-card-foreground',
10+
},
11+
};
12+
13+
export const cardHeaderClassNames = {
14+
base: 'flex flex-col gap-1.5 px-6',
15+
};
16+
17+
export const cardTitleClassNames = {
18+
base: 'font-semibold leading-none',
19+
light: 'text-foreground',
20+
dark: 'text-dark-foreground',
21+
};
22+
23+
export const cardDescriptionClassNames = {
24+
base: 'text-sm',
25+
light: 'text-muted-foreground',
26+
dark: 'text-dark-muted-foreground',
27+
};
28+
29+
export const cardContentClassNames = {
30+
base: 'px-6',
31+
};
32+
33+
export const cardFooterClassNames = {
34+
base: 'flex flex-row items-center px-6',
35+
};

docs/pages/components/_meta.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@
66
"avatar": "Avatar",
77
"skeleton": "Skeleton",
88
"badge": "Badge",
9-
"breadcrumb": "Breadcrumb"
9+
"breadcrumb": "Breadcrumb",
10+
"card": "Card"
1011
}

0 commit comments

Comments
 (0)