|
1 |
| -import React, { ReactNode } from "react" |
| 1 | +import type { ImageProps } from "next/image" |
2 | 2 | import { useTranslation } from "next-i18next"
|
3 |
| -import { |
4 |
| - Badge, |
5 |
| - Box, |
6 |
| - Center, |
7 |
| - Flex, |
8 |
| - Heading, |
9 |
| - HStack, |
10 |
| - TextProps, |
11 |
| -} from "@chakra-ui/react" |
| 3 | +import type { ReactNode } from "react" |
| 4 | +import { Badge } from "@chakra-ui/react" |
12 | 5 |
|
13 | 6 | import { ButtonLink } from "@/components/Buttons"
|
14 |
| -import { Image, type ImageProps } from "@/components/Image" |
15 |
| -import Text from "@/components/OldText" |
16 | 7 |
|
| 8 | +import { cn } from "@/lib/utils/cn" |
| 9 | + |
| 10 | +import { Center, Flex, HStack } from "./ui/flex" |
17 | 11 | import GitStars from "./GitStars"
|
| 12 | +import { TwImage } from "./Image" |
18 | 13 |
|
19 | 14 | type SubjectBadgeProps = {
|
20 | 15 | subject: string
|
21 |
| - children: React.ReactNode |
| 16 | + children: ReactNode |
22 | 17 | }
|
23 | 18 |
|
24 | 19 | const SubjectBadge = ({ subject, children }: SubjectBadgeProps) => {
|
@@ -56,7 +51,7 @@ const SubjectBadge = ({ subject, children }: SubjectBadgeProps) => {
|
56 | 51 | }
|
57 | 52 |
|
58 | 53 | export type ProductCardProps = {
|
59 |
| - children?: React.ReactNode |
| 54 | + children?: ReactNode |
60 | 55 | url: string
|
61 | 56 | background: string
|
62 | 57 | image: ImageProps["src"]
|
@@ -87,71 +82,53 @@ const ProductCard = ({
|
87 | 82 | hideStars = false,
|
88 | 83 | }: ProductCardProps) => {
|
89 | 84 | const { t } = useTranslation("common")
|
90 |
| - const DESCRIPTION_STYLES: TextProps = { |
91 |
| - opacity: 0.8, |
92 |
| - fontSize: "sm", |
93 |
| - mb: 2, |
94 |
| - lineHeight: "140%", |
95 |
| - } |
96 | 85 |
|
97 | 86 | return (
|
98 | 87 | <Flex
|
99 |
| - flexDirection="column" |
100 |
| - justifyContent="space-between" |
101 |
| - color="text" |
102 |
| - background="searchBackground" |
103 |
| - boxShadow="0px 14px 66px rgba(0, 0, 0, 0.07)" |
104 |
| - borderRadius="base" |
105 |
| - border="1px" |
106 |
| - borderColor="lightBorder" |
107 |
| - textDecoration="none" |
108 |
| - _hover={{ |
109 |
| - transition: "transform 0.1s", |
110 |
| - transform: "scale(1.02)", |
111 |
| - }} |
| 88 | + className={cn( |
| 89 | + "text-text bg-searchBackground flex-col justify-between", |
| 90 | + "shadow-product-card", |
| 91 | + "rounded-base border border-gray-100 no-underline", |
| 92 | + "hover:scale-[1.02] hover:transition-transform" |
| 93 | + )} |
112 | 94 | >
|
113 | 95 | <Center
|
114 |
| - background={bgProp} |
115 |
| - boxShadow="inset 0px -1px 0px rgba(0, 0, 0, 0.1)" |
116 |
| - minH="200px" |
| 96 | + className="min-h-[200px] shadow-product-card-img-container" |
| 97 | + style={{ backgroundColor: bgProp }} |
117 | 98 | >
|
118 |
| - <Image |
119 |
| - src={image} |
120 |
| - alt={alt} |
121 |
| - height="100" |
122 |
| - alignSelf="center" |
123 |
| - maxW={{ base: "311px", sm: "372px" }} |
124 |
| - maxH="257px" |
125 |
| - /> |
| 99 | + <TwImage src={image} alt={alt} className="w-[100px] self-center" /> |
126 | 100 | </Center>
|
127 |
| - <Flex flexDirection="column" p={6} textAlign="start" height="100%"> |
| 101 | + <Flex className="h-full flex-col p-6 text-left"> |
128 | 102 | {githubRepoStars > 0 && (
|
129 | 103 | <GitStars
|
130 | 104 | gitHubRepo={{ url: githubUrl, stargazerCount: githubRepoStars }}
|
131 | 105 | hideStars={hideStars}
|
132 | 106 | />
|
133 | 107 | )}
|
134 |
| - <Heading |
135 |
| - as="h3" |
136 |
| - fontSize="2xl" |
137 |
| - fontWeight={600} |
138 |
| - mt={githubRepoStars > 0 ? 8 : 12} |
139 |
| - mb={3} |
| 108 | + <h3 |
| 109 | + className={cn( |
| 110 | + "mb-3 text-2xl font-semibold", |
| 111 | + githubRepoStars > 0 ? "mt-8" : "mt-12" |
| 112 | + )} |
140 | 113 | >
|
141 | 114 | {name}
|
142 |
| - </Heading> |
143 |
| - {description && <Text {...DESCRIPTION_STYLES}>{description}</Text>} |
144 |
| - {note.length > 0 && <Text {...DESCRIPTION_STYLES}>Note: {note}</Text>} |
145 |
| - {children && <Box mt={4}>{children}</Box>} |
| 115 | + </h3> |
| 116 | + {description && ( |
| 117 | + <p className="mb-2 text-sm leading-xs opacity-80">{description}</p> |
| 118 | + )} |
| 119 | + {note.length > 0 && ( |
| 120 | + <p className="mb-2 text-sm leading-xs opacity-80">Note: {note}</p> |
| 121 | + )} |
| 122 | + {children && <div className="mt-4">{children}</div>} |
146 | 123 | </Flex>
|
147 |
| - <HStack mt={5} mb={2} px={6} spacing={3}> |
| 124 | + <HStack className="mb-2 mt-5 gap-3 px-6"> |
148 | 125 | {subjects &&
|
149 | 126 | subjects.map((subject, idx) => (
|
150 | 127 | <SubjectBadge key={idx} subject={subject}>
|
151 | 128 | {subject}
|
152 | 129 | </SubjectBadge>
|
153 | 130 | ))}
|
154 |
| - {githubRepoLanguages.length && |
| 131 | + {githubRepoLanguages.length > 0 && |
155 | 132 | githubRepoLanguages.map((name, idx: number) => (
|
156 | 133 | <SubjectBadge key={idx} subject={name}>
|
157 | 134 | {name.toUpperCase()}
|
|
0 commit comments