Skip to content

Commit 6381f6a

Browse files
authored
Merge pull request #13960 from saurabhburade/shadcn-migrate/AssetDownload-image-artist
Shadcn migrate - AssetDownload - AssetDownloadArtist - AssetDownloadImage
2 parents 31e5ed3 + 86e1f36 commit 6381f6a

File tree

3 files changed

+29
-37
lines changed

3 files changed

+29
-37
lines changed

src/components/AssetDownload/AssetDownloadArtist.tsx

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
import { useTranslation } from "next-i18next"
2-
import { Flex } from "@chakra-ui/react"
32

43
import Emoji from "@/components/Emoji"
5-
import Link from "@/components/Link"
6-
import Text from "@/components/OldText"
4+
5+
import { cn } from "@/lib/utils/cn"
6+
7+
import { Flex } from "../ui/flex"
8+
import { BaseLink } from "../ui/Link"
79

810
type AssetDownloadArtistProps = {
911
artistName: string
@@ -16,21 +18,13 @@ const AssetDownloadArtist = ({
1618
}: AssetDownloadArtistProps) => {
1719
const { t } = useTranslation("page-assets")
1820
return (
19-
<Flex
20-
mb="4"
21-
border="1px"
22-
borderTop="none"
23-
borderColor="white700"
24-
py="2"
25-
px="4"
26-
borderRadius="0 0 4px 4px"
27-
>
28-
<Flex me="2" fontSize="md" textColor="text300">
21+
<Flex className={cn("mb-4 border border-t-0", "rounded-b px-4 py-2")}>
22+
<Flex className="me-2">
2923
<Emoji text=":artist_palette:" className="me-2 text-2xl" />
3024
{t("page-assets-download-artist")}
3125
</Flex>
32-
{artistUrl && <Link href={artistUrl}>{artistName}</Link>}
33-
{!artistUrl && <Text m="0">{artistName}</Text>}
26+
{artistUrl && <BaseLink href={artistUrl}>{artistName}</BaseLink>}
27+
{!artistUrl && <p>{artistName}</p>}
3428
</Flex>
3529
)
3630
}

src/components/AssetDownload/AssetDownloadImage.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
import { Center } from "@chakra-ui/react"
1+
import { ImageProps } from "next/image"
22

3-
import { Image, type ImageProps } from "@/components/Image"
3+
import { TwImage } from "../Image"
4+
import { Center } from "../ui/flex"
45

56
interface AssetDownloadImageProps {
67
image: ImageProps["src"]
78
alt: string
89
}
910

1011
const AssetDownloadImage = ({ image, alt }: AssetDownloadImageProps) => (
11-
<Center border="1px" borderColor="white700" p="8" w="full">
12-
<Image src={image} alt={alt} w="full" alignSelf="center" />
12+
<Center className="w-full border p-8">
13+
<TwImage src={image} alt={alt} className="w-full self-center" />
1314
</Center>
1415
)
1516

src/components/AssetDownload/index.tsx

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
11
import { extname } from "path"
22

3-
import type { StaticImageData } from "next/image"
3+
import { BaseHTMLAttributes } from "react"
4+
import type { ImageProps, StaticImageData } from "next/image"
45
import { useTranslation } from "next-i18next"
5-
import { Box, Flex, type FlexProps } from "@chakra-ui/react"
66

77
import AssetDownloadArtist from "@/components/AssetDownload/AssetDownloadArtist"
88
import AssetDownloadImage from "@/components/AssetDownload/AssetDownloadImage"
9-
import { ButtonLink } from "@/components/Buttons"
10-
import type { ImageProps } from "@/components/Image"
11-
import OldHeading from "@/components/OldHeading"
129

10+
import { cn } from "@/lib/utils/cn"
1311
import { trackCustomEvent } from "@/lib/utils/matomo"
1412

13+
import { ButtonLink } from "../ui/buttons/Button"
14+
import { Flex, Stack } from "../ui/flex"
15+
1516
type AssetDownloadProps = {
1617
title: string
1718
alt: string
1819
artistName?: string
1920
artistUrl?: string
2021
image: ImageProps["src"]
2122
svgUrl?: string
22-
} & FlexProps
23+
} & BaseHTMLAttributes<HTMLDivElement>
2324

2425
const AssetDownload = ({
2526
alt,
@@ -28,6 +29,7 @@ const AssetDownload = ({
2829
image,
2930
svgUrl,
3031
title,
32+
className,
3133
...props
3234
}: AssetDownloadProps) => {
3335
const { t } = useTranslation(["page-assets"])
@@ -41,23 +43,18 @@ const AssetDownload = ({
4143
const imgSrc = (image as StaticImageData).src
4244

4345
return (
44-
<Flex
45-
flexDirection="column"
46-
justifyContent="space-between"
47-
m={4}
48-
p={0}
46+
<Stack
47+
className={cn("m-4 justify-between gap-0 p-0", className)}
4948
{...props}
5049
>
51-
<OldHeading as="h4" fontSize={{ base: "md", md: "xl" }} fontWeight="500">
52-
{title}
53-
</OldHeading>
54-
<Box>
50+
<h4 className="my-8 text-md font-medium md:text-xl">{title}</h4>
51+
<div>
5552
<AssetDownloadImage image={image} alt={alt} />
5653
{artistName && (
5754
<AssetDownloadArtist artistName={artistName} artistUrl={artistUrl} />
5855
)}
59-
</Box>
60-
<Flex gap={5} mt={4}>
56+
</div>
57+
<Flex className="mt-4 gap-5">
6158
<ButtonLink
6259
href={imgSrc}
6360
onClick={matomoHandler}
@@ -73,7 +70,7 @@ const AssetDownload = ({
7370
</ButtonLink>
7471
)}
7572
</Flex>
76-
</Flex>
73+
</Stack>
7774
)
7875
}
7976

0 commit comments

Comments
 (0)