Skip to content

Commit

Permalink
⚡️: size->variant 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
nrkcode committed Jan 24, 2025
1 parent 148eb3f commit 0fe18dc
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 26 deletions.
16 changes: 5 additions & 11 deletions src/common/components/card/new-card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,33 @@
import {
cardVariants,
import type {
MiniCardPT,
TbCardHeaderPT,
TbCardPT,
} from "@/common/components/card/new-card/types"
import { cardVariants } from "@/common/components/card/new-card/types"
import { cn } from "@/util/utils"

export function TbCard({
className,
children,
size,
variant,
color,
...rest
}: TbCardPT) {
return (
<div {...rest} className={cn(cardVariants({ size, color }), className)}>
<div {...rest} className={cn(cardVariants({ variant, color }), className)}>
{children}
</div>
)
}

export function TbCardHeader({
className,
children,
title,
rightArea,
sideTitle,
}: TbCardHeaderPT) {
return (
<div
className={cn(
className,
"flex flex-col gap-3 space-y-1.5 p-3 md:gap-5 md:p-5",
)}
>
<div className="flex flex-col gap-3 space-y-1.5 p-3 md:gap-5 md:p-5">
<div className="flex flex-col">
{title && (
<div className="flex h-fit justify-between">
Expand Down
18 changes: 9 additions & 9 deletions src/common/components/card/new-card/types.ts
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
import { cva, VariantProps } from "class-variance-authority"
import { ReactNode } from "react"
import type { VariantProps } from "class-variance-authority"
import { cva } from "class-variance-authority"
import type { ReactNode } from "react"

export const cardVariants = cva("shadow-md", {
variants: {
variant: {
default: "rounded-2xl",
mini: "flex-col gap-2 rounded-xl p-6",
},
color: {
default: "bg-[#FAFAFA]",
light: "bg-[#F6FCF3]",
deep: "bg-[#EFF6F1]",
pastelGreen: "bg-tbPastelGreen",
},
size: {
default: "rounded-2xl",
mini: "flex-col gap-2 rounded-xl p-6",
},
},
defaultVariants: {
variant: "default",
color: "default",
size: "default",
},
})

export type TbCardPT = {
className?: string
children?: ReactNode
size?: VariantProps<typeof cardVariants>["size"]
variant?: VariantProps<typeof cardVariants>["variant"]
color?: VariantProps<typeof cardVariants>["color"]
}

export type TbCardHeaderPT = {
className?: string
children?: ReactNode
title?: string
rightArea?: ReactNode
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { MiniCardPT } from "@/common/components/card/new-card/types"
import {
MiniCardContent,
MiniCardHeader,
TbCard,
} from "@/common/components/card/new-card"
import type { MiniCardPT } from "@/common/components/card/new-card/types"
import { usePriceCardData } from "@/features/trading-dashboard/hook/usePriceCardData"

type PriceCardPT = {
Expand All @@ -24,7 +24,11 @@ export function PriceCard({ setActiveChart }: PriceCardPT) {
}}
className="text-left"
>
<TbCard size="mini" color={idx ? "deep" : "light"} className="h-full">
<TbCard
variant="mini"
color={idx ? "deep" : "light"}
className="h-full"
>
<MiniCardHeader title={items.title} />
<MiniCardContent
value={items.value}
Expand Down
14 changes: 10 additions & 4 deletions src/features/trading-dashboard/components/slide-card/index.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import type { MiniCardPT } from "@/common/components/card/new-card/types"
import { useEffect, useState } from "react"

import {
MiniCardContent,
MiniCardHeader,
TbCard,
} from "@/common/components/card/new-card"
import { useEffect, useState } from "react"
import type { MiniCardPT } from "@/common/components/card/new-card/types"
import { timeCardDatas } from "@/features/trading-dashboard/components/slide-card/data"

export function TradingVolumeCards() {
const [data, setData] = useState(timeCardDatas[0])

useEffect(() => {
const transformCard = setInterval(() => {
setInterval(() => {
setData((prevData) =>
prevData === timeCardDatas[0] ? timeCardDatas[1] : timeCardDatas[0],
)
Expand All @@ -21,7 +22,12 @@ export function TradingVolumeCards() {
return (
<div className="grid w-full grid-cols-2 gap-4">
{data.map((items: MiniCardPT, idx) => (
<TbCard size="mini" color={idx ? "deep" : "light"} className="h-full">
<TbCard
key={idx}
variant="mini"
color={idx ? "deep" : "light"}
className="h-full"
>
<MiniCardHeader title={items.title} />
<MiniCardContent value={items.value} unit={items.unit} />
</TbCard>
Expand Down

0 comments on commit 0fe18dc

Please sign in to comment.