"use client"; import Image from "next/image"; import { useTranslation } from "../../contexts/MessagesContext"; import MultiSelect from "../MultiSelect"; import type { RuleCardViewProps } from "./RuleCard.types"; export function RuleCardView({ title, description, icon, backgroundColor, className, onClick, onKeyDown, expanded, size, categories, logoUrl, logoAlt, communityInitials, }: RuleCardViewProps) { const t = useTranslation("ruleCard"); const ariaLabel = t("ariaLabel")?.replace("{title}", title) || title; // Size-based styling const isLarge = size === "L"; const isMedium = size === "M"; const isSmall = size === "S"; const isExtraSmall = size === "XS"; // Card dimensions - fixed width for expanded states (568px for L, 398px for M per Figma) // XS and S don't have fixed widths when expanded const cardPadding = isLarge || isSmall ? "p-[24px]" : isMedium ? "p-[16px]" : "pb-[24px] pt-[12px] px-[12px]"; // XS: asymmetric padding const cardGap = expanded ? "gap-[16px]" : isLarge ? "gap-[10px]" : isMedium ? "gap-[12px]" : "gap-[18px]"; // XS and S: 18px gap const cardWidth = expanded ? isLarge ? "w-[568px]" : isMedium ? "w-[398px]" : "" // XS and S: no fixed width : ""; // Logo/Icon dimensions // For S: 80px container with 12px padding = 56px icon area // For XS: 40px container with 16px padding = 8px icon area (very small, but matches Figma) const logoSize = isLarge ? 103 : isMedium ? 56 : isSmall ? 56 // S: 80px container - 12px padding * 2 = 56px icon : 8; // XS: 40px container - 16px padding * 2 = 8px icon const logoContainerClass = isLarge ? "size-[103px]" : isMedium ? "size-[56px]" : isSmall ? "size-[80px]" // S: 80px container : "size-[40px]"; // XS: 40px container // Title typography const titleClass = isLarge ? "font-bricolage-grotesque font-extrabold text-[36px] leading-[44px]" : isMedium ? "font-bricolage-grotesque font-bold text-[24px] leading-[32px]" : isSmall ? "font-bricolage-grotesque font-bold text-[28px] leading-[36px]" // S: 28px, bold, Bricolage : "font-inter font-bold text-[20px] leading-[28px]"; // XS: 20px, bold, Inter // Description typography const descriptionClass = isLarge ? "font-inter font-medium text-[18px] leading-[24px]" : isMedium ? "font-inter font-medium text-[14px] leading-[16px]" : isSmall ? "font-inter font-medium text-[14px] leading-[16px]" // S: 14px, medium, Inter : "font-inter font-medium text-[12px] leading-[14px]"; // XS: 12px, medium, Inter // Render logo/icon const renderLogo = () => { if (logoUrl) { // Check if it's a localhost URL or external URL that needs regular img tag const isLocalhost = logoUrl.startsWith("http://localhost") || logoUrl.startsWith("https://localhost"); const containerClass = `${logoContainerClass} relative rounded-full overflow-hidden mix-blend-luminosity ${isSmall ? "p-[12px]" : isExtraSmall ? "p-[16px]" : ""}`; if (isLocalhost) { return (
{description}
{description}