From 914e17ea3e631e42c0d6cbf1a849a57a18931de4 Mon Sep 17 00:00:00 2001 From: "Josh Berman [SSW]" <137844305+joshbermanssw@users.noreply.github.com> Date: Thu, 16 Jan 2025 13:23:28 +1100 Subject: [PATCH] =?UTF-8?q?=F0=9F=92=84=20Avoid=20Mega-Menu=20in=20Footer?= =?UTF-8?q?=20(#2745)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add conditional group click --- components/layout/Footer.tsx | 55 +++++++++++++++++++++++++----------- 1 file changed, 39 insertions(+), 16 deletions(-) diff --git a/components/layout/Footer.tsx b/components/layout/Footer.tsx index d4ae8d3f2..e6dbe200c 100644 --- a/components/layout/Footer.tsx +++ b/components/layout/Footer.tsx @@ -37,13 +37,19 @@ const footerLinks = [ }, ]; -const LinkGroup = ({ item }: { item: { children: any[]; label: string } }) => { - const [open, setOpen] = React.useState(false); - +const LinkGroup = ({ item, isOpen, onClick }: { + item: { children: any[]; label: string }; + isOpen: boolean; + onClick: () => void; +}) => { return (
setOpen(!open)} + className={`inline-block drop-shadow-sm relative opacity-90 text-white uppercase text-lg lg:text-xl font-tuner transition duration-150 ease-out ${isOpen ? 'open' : ''}`} + open={isOpen} + onClick={(e) => { + e.preventDefault(); + onClick(); + }} > {item.label} @@ -88,6 +94,14 @@ const SocialLink = ({ link, children }) => { }; export const Footer = () => { + const [openGroups, setOpenGroups] = React.useState<{ [columnIndex: number]: number | null }>({}); + + const handleGroupClick = (columnIndex: number, groupIndex: number) => { + setOpenGroups((prev) => ({ + ...prev, + [columnIndex]: prev[columnIndex] === groupIndex ? null : groupIndex, + })); + }; return (
@@ -111,23 +125,32 @@ export const Footer = () => { )} {column.footerItem.map((item, idx) => { return item.items ? ( - ({ - label: subItem.label, - link: subItem.href, - })), - }} /> + ({ + label: subItem.label, + link: subItem.href, + })), + }} + isOpen={openGroups[columnIndex] === idx} + onClick={() => handleGroupClick(columnIndex, idx)} + /> ) : ( - + ); })}
); })} + {/* Social links column */}
{FooterData.Column4.footerItem.map((socialItem, idx) => (