feat(LOY-10): dynamic icons based on reward id
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import { mapRewardToIcon } from "./data"
|
||||
|
||||
import { IconProps } from "@/types/components/icon"
|
||||
|
||||
interface RewardIconProps extends IconProps {
|
||||
rewardId: string
|
||||
size?: "small" | "medium" | "large"
|
||||
}
|
||||
|
||||
// Original SVG aspect ratio is 358:202 (≈1.77:1)
|
||||
const sizeMap = {
|
||||
small: { width: 120, height: 68 }, // 40% of card width
|
||||
medium: { width: 180, height: 102 }, // 60% of card width
|
||||
large: { width: 240, height: 135 }, // 80% of card width
|
||||
} as const
|
||||
|
||||
export function RewardIcon({
|
||||
rewardId,
|
||||
size = "medium",
|
||||
...props
|
||||
}: RewardIconProps) {
|
||||
const IconComponent = mapRewardToIcon(rewardId)
|
||||
if (!IconComponent) return null
|
||||
|
||||
return (
|
||||
<IconComponent
|
||||
{...props}
|
||||
width={sizeMap[size].width}
|
||||
height={sizeMap[size].height}
|
||||
/>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user