Rule Stack interactive states and analytics

This commit is contained in:
adilallo
2025-08-24 21:54:04 -06:00
parent 1ff5d13d2e
commit 7c814de28e
2 changed files with 44 additions and 1 deletions
+34 -1
View File
@@ -6,10 +6,43 @@ const RuleCard = ({
icon, icon,
backgroundColor = "bg-[var(--color-community-teal-100)]", backgroundColor = "bg-[var(--color-community-teal-100)]",
className = "", className = "",
onClick,
}) => { }) => {
const handleClick = () => {
// Basic analytics event tracking
if (typeof window !== "undefined" && window.gtag) {
window.gtag("event", "template_selected", {
template_name: title,
template_type: "governance_pattern",
});
}
// Custom analytics event for other tracking systems
if (typeof window !== "undefined" && window.analytics) {
window.analytics.track("Template Selected", {
templateName: title,
templateType: "governance_pattern",
});
}
if (onClick) onClick();
};
const handleKeyDown = (event) => {
if (event.key === "Enter" || event.key === " ") {
event.preventDefault();
handleClick();
}
};
return ( return (
<div <div
className={`${backgroundColor} rounded-[var(--radius-measures-radius-small)] pt-[var(--spacing-scale-012)] pr-[var(--spacing-scale-012)] pl-[var(--spacing-scale-012)] pb-[var(--spacing-scale-024)] md:p-[var(--spacing-scale-024)] md:h-[210px] lg:h-[277px] flex flex-col gap-[18px] shadow-lg backdrop-blur-sm ${className}`} className={`${backgroundColor} rounded-[var(--radius-measures-radius-small)] pt-[var(--spacing-scale-012)] pr-[var(--spacing-scale-012)] pl-[var(--spacing-scale-012)] pb-[var(--spacing-scale-024)] md:p-[var(--spacing-scale-024)] md:h-[210px] lg:h-[277px] flex flex-col gap-[18px] shadow-lg backdrop-blur-sm transition-all duration-500 ease-in-out hover:shadow-xl hover:scale-[1.02] focus:outline-none focus:ring-2 focus:ring-[var(--color-community-teal-500)] focus:ring-offset-2 cursor-pointer min-h-[44px] min-w-[44px] ${className}`}
tabIndex={0}
role="button"
aria-label={`Learn more about ${title} governance pattern`}
onClick={handleClick}
onKeyDown={handleKeyDown}
> >
{/* Header Container */} {/* Header Container */}
<div className="grid grid-cols-[auto_1fr] h-[72px] md:h-[80px] lg:h-[138px] border-b border-[var(--color-surface-default-primary)]"> <div className="grid grid-cols-[auto_1fr] h-[72px] md:h-[80px] lg:h-[138px] border-b border-[var(--color-surface-default-primary)]">
+10
View File
@@ -6,6 +6,12 @@ import Button from "./Button";
import Image from "next/image"; import Image from "next/image";
const RuleStack = ({ children, className = "" }) => { const RuleStack = ({ children, className = "" }) => {
const handleTemplateClick = (templateName) => {
console.log(`Template selected: ${templateName}`);
// This would typically navigate to template details or open a modal
// For now, we'll just log the selection
};
return ( return (
<div <div
className={`w-full bg-transparent py-[var(--spacing-scale-032)] px-[var(--spacing-scale-020)] md:py-[var(--spacing-scale-048)] md:px-[var(--spacing-scale-032)] xmd:py-[var(--spacing-scale-056)] xmd:px-[var(--spacing-scale-032)] lg:py-[var(--spacing-scale-064)] lg:px-[var(--spacing-scale-064)] xl:py-[var(--spacing-scale-064)] xl:px-[var(--spacing-scale-096)] flex flex-col gap-[var(--spacing-scale-024)] xmd:gap-[var(--spacing-scale-032)] lg:gap-[var(--spacing-scale-040)] ${className}`} className={`w-full bg-transparent py-[var(--spacing-scale-032)] px-[var(--spacing-scale-020)] md:py-[var(--spacing-scale-048)] md:px-[var(--spacing-scale-032)] xmd:py-[var(--spacing-scale-056)] xmd:px-[var(--spacing-scale-032)] lg:py-[var(--spacing-scale-064)] lg:px-[var(--spacing-scale-064)] xl:py-[var(--spacing-scale-064)] xl:px-[var(--spacing-scale-096)] flex flex-col gap-[var(--spacing-scale-024)] xmd:gap-[var(--spacing-scale-032)] lg:gap-[var(--spacing-scale-040)] ${className}`}
@@ -29,6 +35,7 @@ const RuleStack = ({ children, className = "" }) => {
/> />
} }
backgroundColor="bg-[var(--color-surface-default-brand-lime)]" backgroundColor="bg-[var(--color-surface-default-brand-lime)]"
onClick={() => handleTemplateClick("Consensus clusters")}
/> />
<RuleCard <RuleCard
title="Consensus" title="Consensus"
@@ -43,6 +50,7 @@ const RuleStack = ({ children, className = "" }) => {
/> />
} }
backgroundColor="bg-[var(--color-surface-default-brand-rust)]" backgroundColor="bg-[var(--color-surface-default-brand-rust)]"
onClick={() => handleTemplateClick("Consensus")}
/> />
<RuleCard <RuleCard
title="Elected Board" title="Elected Board"
@@ -57,6 +65,7 @@ const RuleStack = ({ children, className = "" }) => {
/> />
} }
backgroundColor="bg-[var(--color-surface-default-brand-red)]" backgroundColor="bg-[var(--color-surface-default-brand-red)]"
onClick={() => handleTemplateClick("Elected Board")}
/> />
<RuleCard <RuleCard
title="Petition" title="Petition"
@@ -71,6 +80,7 @@ const RuleStack = ({ children, className = "" }) => {
/> />
} }
backgroundColor="bg-[var(--color-surface-default-brand-teal)]" backgroundColor="bg-[var(--color-surface-default-brand-teal)]"
onClick={() => handleTemplateClick("Petition")}
/> />
</div> </div>