Add interactivity and accessibility
This commit is contained in:
@@ -25,30 +25,42 @@ const FeatureGrid = ({ title, subtitle, className = "" }) => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* MiniCard Grid */}
|
{/* MiniCard Grid */}
|
||||||
<div className="grid grid-cols-2 md:grid-cols-4 gap-[var(--spacing-scale-012)] mt-[var(--spacing-scale-048)] lg:mt-0 lg:flex-grow lg:shrink-0">
|
<div
|
||||||
|
className="grid grid-cols-2 md:grid-cols-4 gap-[var(--spacing-scale-012)] mt-[var(--spacing-scale-048)] lg:mt-0 lg:flex-grow lg:shrink-0"
|
||||||
|
role="grid"
|
||||||
|
aria-label="Feature tools and services"
|
||||||
|
>
|
||||||
<MiniCard
|
<MiniCard
|
||||||
backgroundColor="bg-[var(--color-surface-default-brand-royal)]"
|
backgroundColor="bg-[var(--color-surface-default-brand-royal)]"
|
||||||
labelLine1="Decision-making"
|
labelLine1="Decision-making"
|
||||||
labelLine2="support"
|
labelLine2="support"
|
||||||
panelContent="assets/Feature_Support.png"
|
panelContent="assets/Feature_Support.png"
|
||||||
|
ariaLabel="Decision-making support tools"
|
||||||
|
href="#decision-making"
|
||||||
/>
|
/>
|
||||||
<MiniCard
|
<MiniCard
|
||||||
backgroundColor="bg-[#D1FFE2]"
|
backgroundColor="bg-[#D1FFE2]"
|
||||||
labelLine1="Values alignment"
|
labelLine1="Values alignment"
|
||||||
labelLine2="exercises"
|
labelLine2="exercises"
|
||||||
panelContent="assets/Feature_Exercises.png"
|
panelContent="assets/Feature_Exercises.png"
|
||||||
|
ariaLabel="Values alignment exercises"
|
||||||
|
href="#values-alignment"
|
||||||
/>
|
/>
|
||||||
<MiniCard
|
<MiniCard
|
||||||
backgroundColor="bg-[#F4CAFF]"
|
backgroundColor="bg-[#F4CAFF]"
|
||||||
labelLine1="Membership"
|
labelLine1="Membership"
|
||||||
labelLine2="guidance"
|
labelLine2="guidance"
|
||||||
panelContent="assets/Feature_Guidance.png"
|
panelContent="assets/Feature_Guidance.png"
|
||||||
|
ariaLabel="Membership guidance resources"
|
||||||
|
href="#membership-guidance"
|
||||||
/>
|
/>
|
||||||
<MiniCard
|
<MiniCard
|
||||||
backgroundColor="bg-[#CBDDFF]"
|
backgroundColor="bg-[#CBDDFF]"
|
||||||
labelLine1="Conflict resolution"
|
labelLine1="Conflict resolution"
|
||||||
labelLine2="tools"
|
labelLine2="tools"
|
||||||
panelContent="assets/Feature_Tools.png"
|
panelContent="assets/Feature_Tools.png"
|
||||||
|
ariaLabel="Conflict resolution tools"
|
||||||
|
href="#conflict-resolution"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -10,19 +10,27 @@ const MiniCard = ({
|
|||||||
label,
|
label,
|
||||||
labelLine1,
|
labelLine1,
|
||||||
labelLine2,
|
labelLine2,
|
||||||
|
onClick,
|
||||||
|
href,
|
||||||
|
ariaLabel,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
const cardContent = (
|
||||||
<div className={`h-[186px] flex flex-col gap-[7px] ${className}`}>
|
<div className={`h-[186px] flex flex-col gap-[7px] ${className}`}>
|
||||||
{/* Top part - Inner panel */}
|
{/* Top part - Inner panel */}
|
||||||
<div
|
<div
|
||||||
className={`flex-1 rounded-[var(--radius-measures-radius-xlarge)] border border-[1px] py-[var(--spacing-scale-032)] px-[var(--spacing-scale-024)] ${backgroundColor} flex items-center justify-center`}
|
className={`flex-1 rounded-[var(--radius-measures-radius-xlarge)] border border-[1px] py-[var(--spacing-scale-032)] px-[var(--spacing-scale-024)] ${backgroundColor} flex items-center justify-center transition-all duration-200 hover:scale-[1.02] hover:shadow-lg`}
|
||||||
>
|
>
|
||||||
{/* Content for the inner panel */}
|
{/* Content for the inner panel */}
|
||||||
{panelContent && (
|
{panelContent && (
|
||||||
<div className="flex items-center justify-center w-full h-full">
|
<div className="flex items-center justify-center w-full h-full">
|
||||||
<img
|
<img
|
||||||
src={panelContent}
|
src={panelContent}
|
||||||
alt=""
|
alt={
|
||||||
|
ariaLabel ||
|
||||||
|
`${labelLine1} ${labelLine2}` ||
|
||||||
|
label ||
|
||||||
|
"Feature icon"
|
||||||
|
}
|
||||||
className="max-w-[58px] max-h-[58px] w-auto h-auto object-contain"
|
className="max-w-[58px] max-h-[58px] w-auto h-auto object-contain"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,6 +52,56 @@ const MiniCard = ({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// If href is provided, render as a link
|
||||||
|
if (href) {
|
||||||
|
return (
|
||||||
|
<a
|
||||||
|
href={href}
|
||||||
|
className="block focus:outline-none focus:ring-2 focus:ring-[var(--color-surface-default-brand-royal)] focus:ring-offset-2 rounded-[var(--radius-measures-radius-xlarge)] transition-all duration-200 hover:scale-[1.02]"
|
||||||
|
aria-label={
|
||||||
|
ariaLabel || `${labelLine1} ${labelLine2}` || label || "Feature card"
|
||||||
|
}
|
||||||
|
tabIndex={0}
|
||||||
|
>
|
||||||
|
{cardContent}
|
||||||
|
</a>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If onClick is provided, render as a button
|
||||||
|
if (onClick) {
|
||||||
|
return (
|
||||||
|
<button
|
||||||
|
onClick={onClick}
|
||||||
|
className="block w-full text-left focus:outline-none focus:ring-2 focus:ring-[var(--color-surface-default-brand-royal)] focus:ring-offset-2 rounded-[var(--radius-measures-radius-xlarge)] transition-all duration-200 hover:scale-[1.02]"
|
||||||
|
aria-label={
|
||||||
|
ariaLabel || `${labelLine1} ${labelLine2}` || label || "Feature card"
|
||||||
|
}
|
||||||
|
tabIndex={0}
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === "Enter" || e.key === " ") {
|
||||||
|
e.preventDefault();
|
||||||
|
onClick();
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{cardContent}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default render as a div
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="block"
|
||||||
|
aria-label={
|
||||||
|
ariaLabel || `${labelLine1} ${labelLine2}` || label || "Feature card"
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{cardContent}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default MiniCard;
|
export default MiniCard;
|
||||||
|
|||||||
Reference in New Issue
Block a user