Implement S and XS Rule Card

This commit is contained in:
adilallo
2026-02-05 14:18:30 -07:00
parent fc5933e6ba
commit 7e2348048a
5 changed files with 132 additions and 51 deletions
+21 -21
View File
@@ -474,7 +474,7 @@ export default function ComponentsPreview() {
<div className="space-y-[var(--spacing-scale-016)]"> <div className="space-y-[var(--spacing-scale-016)]">
<h3 className="font-inter text-[20px] leading-[24px] font-semibold text-[var(--color-content-default-primary)]"> <h3 className="font-inter text-[20px] leading-[24px] font-semibold text-[var(--color-content-default-primary)]">
Default palette Default palette
</h3> </h3>
<div className="flex flex-wrap items-center gap-[var(--spacing-scale-016)]"> <div className="flex flex-wrap items-center gap-[var(--spacing-scale-016)]">
<Chip <Chip
label="Small" label="Small"
@@ -585,7 +585,7 @@ export default function ComponentsPreview() {
</div> </div>
{/* Inverse palette - on white background */} {/* Inverse palette - on white background */}
<div className="space-y-[var(--spacing-scale-016)]"> <div className="space-y-[var(--spacing-scale-016)]">
<h3 className="font-inter text-[20px] leading-[24px] font-semibold text-[var(--color-content-default-primary)]"> <h3 className="font-inter text-[20px] leading-[24px] font-semibold text-[var(--color-content-default-primary)]">
Inverse palette (on white background) Inverse palette (on white background)
</h3> </h3>
@@ -643,8 +643,8 @@ export default function ComponentsPreview() {
logoUrl="http://localhost:3845/assets/d2513a6ab56f2b2927e8a7c442c06326e7a29541.png" logoUrl="http://localhost:3845/assets/d2513a6ab56f2b2927e8a7c442c06326e7a29541.png"
logoAlt="Mutual Aid Mondays" logoAlt="Mutual Aid Mondays"
onClick={() => console.log("Card clicked: Mutual Aid Mondays")} onClick={() => console.log("Card clicked: Mutual Aid Mondays")}
/> />
</div> </div>
</section> </section>
{/* Collapsed State - Medium */} {/* Collapsed State - Medium */}
@@ -663,16 +663,16 @@ export default function ComponentsPreview() {
logoUrl="http://localhost:3845/assets/d2513a6ab56f2b2927e8a7c442c06326e7a29541.png" logoUrl="http://localhost:3845/assets/d2513a6ab56f2b2927e8a7c442c06326e7a29541.png"
logoAlt="Mutual Aid Mondays" logoAlt="Mutual Aid Mondays"
onClick={() => console.log("Card clicked: Mutual Aid Mondays")} onClick={() => console.log("Card clicked: Mutual Aid Mondays")}
/> />
</div> </div>
</section> </section>
{/* Expanded State - Large */} {/* Expanded State - Large */}
<section className="space-y-[var(--spacing-scale-024)]"> <section className="space-y-[var(--spacing-scale-024)]">
<h2 className="font-bricolage-grotesque text-[32px] leading-[40px] font-bold text-[var(--color-content-default-primary)]"> <h2 className="font-bricolage-grotesque text-[32px] leading-[40px] font-bold text-[var(--color-content-default-primary)]">
Expanded State - Large (L) Expanded State - Large (L)
</h2> </h2>
<div className="bg-[var(--color-surface-default-secondary)] rounded-[var(--radius-300,12px)] p-[var(--spacing-scale-032)] space-y-[var(--spacing-scale-024)]"> <div className="bg-[var(--color-surface-default-secondary)] rounded-[var(--radius-300,12px)] p-[var(--spacing-scale-032)] space-y-[var(--spacing-scale-024)]">
<RuleCard <RuleCard
title="Mutual Aid Mondays" title="Mutual Aid Mondays"
description="Mutual Aid Monday is a grassroots community in Denver, founded in November 2020 by Kelsang Virya, dedicated to supporting neighbors experiencing homelessness." description="Mutual Aid Monday is a grassroots community in Denver, founded in November 2020 by Kelsang Virya, dedicated to supporting neighbors experiencing homelessness."
@@ -684,8 +684,8 @@ export default function ComponentsPreview() {
logoAlt="Mutual Aid Mondays" logoAlt="Mutual Aid Mondays"
categories={ruleCardCategories} categories={ruleCardCategories}
onClick={() => console.log("Card clicked: Mutual Aid Mondays")} onClick={() => console.log("Card clicked: Mutual Aid Mondays")}
/> />
</div> </div>
</section> </section>
{/* Expanded State - Medium */} {/* Expanded State - Medium */}
@@ -706,14 +706,14 @@ export default function ComponentsPreview() {
categories={ruleCardCategories} categories={ruleCardCategories}
onClick={() => console.log("Card clicked: Mutual Aid Mondays")} onClick={() => console.log("Card clicked: Mutual Aid Mondays")}
/> />
</div> </div>
</section> </section>
{/* Different Background Colors */} {/* Different Background Colors */}
<section className="space-y-[var(--spacing-scale-024)]"> <section className="space-y-[var(--spacing-scale-024)]">
<h2 className="font-bricolage-grotesque text-[32px] leading-[40px] font-bold text-[var(--color-content-default-primary)]"> <h2 className="font-bricolage-grotesque text-[32px] leading-[40px] font-bold text-[var(--color-content-default-primary)]">
Different Background Colors Different Background Colors
</h2> </h2>
<div className="bg-[var(--color-surface-default-secondary)] rounded-[var(--radius-300,12px)] p-[var(--spacing-scale-032)] space-y-[var(--spacing-scale-024)]"> <div className="bg-[var(--color-surface-default-secondary)] rounded-[var(--radius-300,12px)] p-[var(--spacing-scale-032)] space-y-[var(--spacing-scale-024)]">
<div className="grid grid-cols-1 md:grid-cols-2 gap-[var(--spacing-scale-024)]"> <div className="grid grid-cols-1 md:grid-cols-2 gap-[var(--spacing-scale-024)]">
<RuleCard <RuleCard
@@ -749,9 +749,9 @@ export default function ComponentsPreview() {
/> />
} }
onClick={() => console.log("Consensus selected")} onClick={() => console.log("Consensus selected")}
/> />
</div> </div>
</div> </div>
</section> </section>
{/* Logo Fallback */} {/* Logo Fallback */}
@@ -769,8 +769,8 @@ export default function ComponentsPreview() {
className="w-[525px]" className="w-[525px]"
communityInitials="CE" communityInitials="CE"
onClick={() => console.log("Community Example selected")} onClick={() => console.log("Community Example selected")}
/> />
</div> </div>
</section> </section>
{/* MultiSelect Component */} {/* MultiSelect Component */}
+2 -2
View File
@@ -17,7 +17,7 @@ export interface RuleCardProps {
className?: string; className?: string;
onClick?: () => void; onClick?: () => void;
expanded?: boolean; expanded?: boolean;
size?: "L" | "M" | "l" | "m"; size?: "XS" | "S" | "M" | "L" | "xs" | "s" | "m" | "l";
categories?: Category[]; categories?: Category[];
logoUrl?: string; logoUrl?: string;
logoAlt?: string; logoAlt?: string;
@@ -33,7 +33,7 @@ export interface RuleCardViewProps {
onClick: () => void; onClick: () => void;
onKeyDown: (_event: React.KeyboardEvent<HTMLDivElement>) => void; onKeyDown: (_event: React.KeyboardEvent<HTMLDivElement>) => void;
expanded: boolean; expanded: boolean;
size: "L" | "M"; size: "XS" | "S" | "M" | "L";
categories?: Category[]; categories?: Category[];
logoUrl?: string; logoUrl?: string;
logoAlt?: string; logoAlt?: string;
+68 -25
View File
@@ -25,33 +25,67 @@ export function RuleCardView({
// Size-based styling // Size-based styling
const isLarge = size === "L"; 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) // Card dimensions - fixed width for expanded states (568px for L, 398px for M per Figma)
const cardPadding = isLarge ? "p-[24px]" : "p-[16px]"; // 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 const cardGap = expanded
? "gap-[16px]" ? "gap-[16px]"
: isLarge ? "gap-[10px]" : "gap-[12px]"; : isLarge
? "gap-[10px]"
: isMedium
? "gap-[12px]"
: "gap-[18px]"; // XS and S: 18px gap
const cardWidth = expanded const cardWidth = expanded
? isLarge ? isLarge
? "w-[568px]" ? "w-[568px]"
: "w-[398px]" : isMedium
? "w-[398px]"
: "" // XS and S: no fixed width
: ""; : "";
// Logo/Icon dimensions // Logo/Icon dimensions
const logoSize = isLarge ? 103 : 56; // 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 const logoContainerClass = isLarge
? "size-[103px]" ? "size-[103px]"
: "size-[56px]"; : isMedium
? "size-[56px]"
: isSmall
? "size-[80px]" // S: 80px container
: "size-[40px]"; // XS: 40px container
// Title typography // Title typography
const titleClass = isLarge const titleClass = isLarge
? "font-bricolage-grotesque font-extrabold text-[36px] leading-[44px]" ? "font-bricolage-grotesque font-extrabold text-[36px] leading-[44px]"
: "font-bricolage-grotesque font-bold text-[24px] leading-[32px]"; : 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 // Description typography
const descriptionClass = isLarge const descriptionClass = isLarge
? "font-inter font-medium text-[18px] leading-[24px]" ? "font-inter font-medium text-[18px] leading-[24px]"
: "font-inter font-medium text-[14px] leading-[16px]"; : 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 // Render logo/icon
const renderLogo = () => { const renderLogo = () => {
@@ -59,29 +93,31 @@ export function RuleCardView({
// Check if it's a localhost URL or external URL that needs regular img tag // 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 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) { if (isLocalhost) {
return ( return (
<div className={`${logoContainerClass} relative rounded-full overflow-hidden mix-blend-luminosity`}> <div className={containerClass}>
{/* eslint-disable-next-line @next/next/no-img-element */} {/* eslint-disable-next-line @next/next/no-img-element */}
<img <img
src={logoUrl} src={logoUrl}
alt={logoAlt || title} alt={logoAlt || title}
width={logoSize} width={logoSize}
height={logoSize} height={logoSize}
className="absolute inset-0 w-full h-full object-cover rounded-full" className={`${isSmall || isExtraSmall ? "w-full h-full" : "absolute inset-0 w-full h-full"} object-cover rounded-full`}
/> />
</div> </div>
); );
} }
return ( return (
<div className={`${logoContainerClass} relative rounded-full overflow-hidden mix-blend-luminosity`}> <div className={containerClass}>
<Image <Image
src={logoUrl} src={logoUrl}
alt={logoAlt || title} alt={logoAlt || title}
width={logoSize} width={logoSize}
height={logoSize} height={logoSize}
className="absolute inset-0 w-full h-full object-cover rounded-full" className={`${isSmall || isExtraSmall ? "w-full h-full" : "absolute inset-0 w-full h-full"} object-cover rounded-full`}
/> />
</div> </div>
); );
@@ -89,16 +125,23 @@ export function RuleCardView({
if (icon) { if (icon) {
return ( return (
<div className={`${logoContainerClass} flex items-center justify-center`}> <div className={`${logoContainerClass} flex items-center justify-center ${isSmall ? "p-[12px]" : isExtraSmall ? "p-[16px]" : ""}`}>
{icon} {icon}
</div> </div>
); );
} }
if (communityInitials) { if (communityInitials) {
const initialsSize = isLarge
? "text-[36px]"
: isMedium
? "text-[24px]"
: isSmall
? "text-[20px]"
: "text-[16px]";
return ( return (
<div className={`${logoContainerClass} rounded-full bg-[var(--color-surface-default-primary)] flex items-center justify-center`}> <div className={`${logoContainerClass} rounded-full bg-[var(--color-surface-default-primary)] flex items-center justify-center`}>
<span className={`${isLarge ? "text-[36px]" : "text-[24px]"} font-bricolage-grotesque font-bold text-[var(--color-content-default-primary,white)]`}> <span className={`${initialsSize} font-bricolage-grotesque font-bold text-[var(--color-content-default-primary,white)]`}>
{communityInitials} {communityInitials}
</span> </span>
</div> </div>
@@ -111,7 +154,7 @@ export function RuleCardView({
return ( return (
<div <div
className={`${backgroundColor} ${cardPadding} ${cardGap} rounded-[var(--radius-measures-radius-small)] shadow-[0px_0px_48px_0px_rgba(0,0,0,0.1)] hover:shadow-[0px_0px_64px_0px_rgba(0,0,0,0.15)] transition-shadow duration-200 flex flex-col items-start justify-center relative ${cardWidth || "w-full"} ${className}`} className={`${backgroundColor} ${cardPadding} ${cardGap} ${isExtraSmall ? "rounded-[var(--measures-radius-200,8px)]" : isSmall ? "rounded-[var(--measures-radius-300,12px)]" : "rounded-[var(--radius-measures-radius-small)]"} shadow-[0px_0px_48px_0px_rgba(0,0,0,0.1)] hover:shadow-[0px_0px_64px_0px_rgba(0,0,0,0.15)] transition-shadow duration-200 flex flex-col items-start justify-center relative ${cardWidth || "w-full"} ${className}`}
tabIndex={0} tabIndex={0}
role="button" role="button"
aria-label={ariaLabel} aria-label={ariaLabel}
@@ -120,23 +163,23 @@ export function RuleCardView({
onKeyDown={onKeyDown} onKeyDown={onKeyDown}
> >
{/* Outermost container with bottom border - taller to match Figma */} {/* Outermost container with bottom border - taller to match Figma */}
<div className={`border-b border-black border-solid flex items-center relative shrink-0 w-full ${isLarge ? "h-[136px]" : "h-[88px]"}`}> <div className={`border-b border-black border-solid flex items-center relative shrink-0 w-full ${isLarge ? "h-[136px]" : isMedium ? "h-[88px]" : isSmall ? "h-[80px]" : "h-[40px]"}`}>
{/* Logo/Icon - fixed width/height, vertically centered, does not touch bottom */} {/* Logo/Icon - fixed width/height, vertically centered, does not touch bottom */}
{renderLogo() && ( {renderLogo() && (
<div className={`flex items-center justify-center shrink-0 ${isLarge ? "w-[103px] h-[103px]" : "w-[56px] h-[56px]"}`}> <div className={`flex items-center justify-center shrink-0 ${isLarge ? "w-[103px] h-[103px]" : isMedium ? "w-[56px] h-[56px]" : isSmall ? "w-[80px] h-[80px]" : "w-[40px] h-[40px]"} ${isSmall || isExtraSmall ? "border-r border-black border-solid" : ""}`}>
{renderLogo()} {renderLogo()}
</div> </div>
)} )}
{/* 16px spacing */} {/* Spacing between icon and title */}
<div className="w-[16px] shrink-0" /> {!isSmall && !isExtraSmall && <div className="w-[16px] shrink-0" />}
{/* Container with no padding and left border - extends full height to touch bottom */} {/* Container with no padding and left border - extends full height to touch bottom */}
{title && ( {title && (
<div className="border-l border-black border-solid flex-1 min-w-0 h-full flex"> <div className={`${!isSmall && !isExtraSmall ? "border-l border-black border-solid" : ""} flex-1 min-w-0 h-full flex`}>
{/* Inner container for header text with padding */} {/* Inner container for header text with padding */}
<div className={`flex ${isLarge ? "px-[16px] py-[24px]" : "px-[16px] py-[12px]"} items-center justify-center w-full`}> <div className={`flex ${isLarge ? "px-[16px] py-[24px]" : isMedium ? "px-[16px] py-[12px]" : isSmall ? "pl-[12px] py-[12px]" : "pl-[8px] py-[8px]"} items-center justify-center w-full`}>
<h3 className={`${titleClass} text-black overflow-hidden text-ellipsis w-full`}> <h3 className={`${titleClass} text-black overflow-hidden text-ellipsis w-full`}>
{title} {title}
</h3> </h3>
</div> </div>
</div> </div>
)} )}
@@ -175,7 +218,7 @@ export function RuleCardView({
</div> </div>
)} )}
{/* Footer: Description */} {/* Footer: Description */}
{description && ( {description && (
<div className="border-t border-black border-solid pt-[16px] relative shrink-0 w-full"> <div className="border-t border-black border-solid pt-[16px] relative shrink-0 w-full">
<p className={`${descriptionClass} text-black`}> <p className={`${descriptionClass} text-black`}>
{description} {description}
@@ -188,8 +231,8 @@ export function RuleCardView({
description && ( description && (
<div className="flex items-center justify-center relative shrink-0 w-full"> <div className="flex items-center justify-center relative shrink-0 w-full">
<p className={`${descriptionClass} text-black flex-1`}> <p className={`${descriptionClass} text-black flex-1`}>
{description} {description}
</p> </p>
</div> </div>
) )
)} )}
+2 -2
View File
@@ -519,10 +519,10 @@ export function normalizeSmallMediumLargeSize(
export function normalizeRuleCardSize( export function normalizeRuleCardSize(
value: string | undefined, value: string | undefined,
defaultValue: "L" = "L" defaultValue: "L" = "L"
): "L" | "M" { ): "XS" | "S" | "M" | "L" {
if (!value) return defaultValue; if (!value) return defaultValue;
const normalized = value.toUpperCase(); const normalized = value.toUpperCase();
if (normalized === "L" || normalized === "M") { if (normalized === "XS" || normalized === "S" || normalized === "M" || normalized === "L") {
return normalized; return normalized;
} }
return defaultValue; return defaultValue;
+39 -1
View File
@@ -39,7 +39,7 @@ export default {
}, },
size: { size: {
control: { type: "select" }, control: { type: "select" },
options: ["L", "M", "l", "m"], options: ["XS", "S", "M", "L", "xs", "s", "m", "l"],
description: "Size variant of the card", description: "Size variant of the card",
}, },
onClick: { action: "clicked" }, onClick: { action: "clicked" },
@@ -186,6 +186,44 @@ export const SizeMedium = {
}, },
}; };
export const SizeSmall = {
args: {
title: "Consensus clusters",
description:
"Units called Circles have the ability to decide and act on matters in their domains, which their members agree on through a Council.",
backgroundColor: "bg-[var(--color-surface-default-brand-lime)]",
expanded: false,
size: "S",
icon: (
<Image
src="assets/Icon_Sociocracy.svg"
alt="Sociocracy"
width={56}
height={56}
/>
),
},
};
export const SizeExtraSmall = {
args: {
title: "Consensus clusters",
description:
"Units called Circles have the ability to decide and act on matters in their domains, which their members agree on through a Council.",
backgroundColor: "bg-[var(--color-surface-default-brand-lime)]",
expanded: false,
size: "XS",
icon: (
<Image
src="assets/Icon_Sociocracy.svg"
alt="Sociocracy"
width={8}
height={8}
/>
),
},
};
export const ExpandedMedium = { export const ExpandedMedium = {
args: { args: {
title: "Mutual Aid Mondays", title: "Mutual Aid Mondays",