Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: migrate HorizontalCard to tailwind #14226

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 18 additions & 16 deletions src/components/HorizontalCard.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,37 @@
import React, { ReactNode } from "react"
import { Box, Flex, FlexProps } from "@chakra-ui/react"

import { cn } from "@/lib/utils/cn"

import Emoji from "./Emoji"
import Text from "./OldText"

export type HorizontalCardProps = Omit<FlexProps, "title"> & {
export interface HorizontalCardProps
extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
emoji: string
emojiClassName?: string
title?: ReactNode
description: ReactNode
children?: ReactNode
}

const HorizontalCard = ({
emoji,
emojiClassName,
title,
description,
children,
className,
...rest
}: HorizontalCardProps) => (
<Flex borderRadius="base" {...rest}>
<Emoji className={cn("text-5xl", className)} text={emoji} />
<Box flexGrow="0" flexShrink="1" flexBasis="75%" ms="8">
<Text fontSize="lg">{title}</Text>
<Text mt="-4" mb="2">
{description}
</Text>
<>{children}</>
</Box>
</Flex>
)
...props
}: HorizontalCardProps) => {
return (
<div className={cn("my-2 flex items-start gap-8", className)} {...props}>
<Emoji text={emoji} className={cn("text-5xl", emojiClassName)} />
<div className="flex-shrink flex-grow-0 basis-3/4 space-y-2">
<div className="text-lg">{title}</div>
<div className="text-base">{description}</div>
Comment on lines +29 to +30
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we could still use p tags here to keep the semantics

Suggested change
<div className="text-lg">{title}</div>
<div className="text-base">{description}</div>
<p className="text-lg">{title}</p>
<p className="text-base">{description}</p>

{children}
</div>
</div>
)
}

export default HorizontalCard
2 changes: 1 addition & 1 deletion src/pages/eth.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ const CardContainer = (props: FlexProps) => (
)

const TokenCard = (props: ComponentProps<typeof HorizontalCard>) => (
<HorizontalCard minW="full" my={2} mx={0} borderRadius={0} {...props} />
<HorizontalCard {...props} className="mx-0 my-2 min-w-full rounded-none" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to use the cn function here to merge the classNames. Otherwise, we will always override the className passed to TokenCard.

Suggested change
<HorizontalCard {...props} className="mx-0 my-2 min-w-full rounded-none" />
<HorizontalCard className={cn("mx-0 my-2 min-w-full rounded-none", className)} {...props} />

)

const TextDivider = () => (
Expand Down
4 changes: 2 additions & 2 deletions src/pages/gas.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -303,8 +303,8 @@ const GasPage = () => {
key={benefit.emoji}
emoji={benefit.emoji}
description={benefit.description}
className="text-5xl"
align="center"
emojiClassName="text-5xl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5xl is the default size applied in HorizontalCard. We can remove, its just redundant.

Suggested change
emojiClassName="text-5xl"

className="flex items-center py-2"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
className="flex items-center py-2"
className="flex items-center"

/>
</Box>
))}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/stablecoins.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ const StablecoinsPage = ({ markets, marketsHasError }) => {
<HorizontalCard
emoji={token.emoji}
description={token.description}
className="text-5xl"
emojiClassName="text-5xl"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emojiClassName="text-5xl"

/>
</Box>
))}
Expand Down
16 changes: 4 additions & 12 deletions src/pages/wallets/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ export const StyledCard = (props: ComponentPropsWithRef<typeof Card>) => (
)
const ChecklistItem = (props: HorizontalCardProps) => (
<HorizontalCard
border={0}
display="flex"
className="text-2xl"
alignItems="flex-start"
mb={4}
emojiClassName="text-2xl"
className="flex-start mb-4 flex border-0"
{...props}
/>
)
Expand Down Expand Up @@ -362,16 +359,11 @@ const WalletsPage = () => {
<Box>
{types.map((type, idx) => (
<HorizontalCard
minWidth="100%"
marginTop={2}
marginBottom={2}
ms={0}
me={0}
key={idx}
emoji={type.emoji}
description={type.description}
className="text-[2.5rem]"
alignItems="center"
className="my-0.5 w-[100%] items-center"
emojiClassName={"text-[2.5rem]"}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
emojiClassName={"text-[2.5rem]"}
emojiClassName="text-[2.5rem]"

/>
))}
</Box>
Expand Down
Loading