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