From f1c3e90237318ef27bb317b571b4f32c367c8c46 Mon Sep 17 00:00:00 2001 From: Michael Gummere Date: Mon, 6 May 2024 11:49:22 -0400 Subject: [PATCH] footer 2.0: the meta --- components/Footer/Footer.tsx | 94 ++++++++++++++---------------------- 1 file changed, 37 insertions(+), 57 deletions(-) diff --git a/components/Footer/Footer.tsx b/components/Footer/Footer.tsx index 7af6a63..fbae739 100644 --- a/components/Footer/Footer.tsx +++ b/components/Footer/Footer.tsx @@ -31,7 +31,7 @@ const iconMap = { export default function Footer() { let menus = [ { - title: "Find my projects here!", + title: "Projects", children: [ { name: "GitLab", href: "https://gitlab.com/Chrono-byte" }, { name: "GitHub", href: "https://github.com/Chrono-byte" }, @@ -64,8 +64,9 @@ export default function Footer() { }, ]; - const iconsDisplay: JSX.Element[] = []; - const icons2Display: JSX.Element[] = []; + const iconsDisplay: { + [key: string]: JSX.Element[]; + } = {}; // only display the socials that are enabled const enabledSocials: string[] = [ @@ -93,42 +94,29 @@ export default function Footer() { return (a.name && b.name) ? a.name.localeCompare(b.name) : 0; }); + // add the menu to the iconsDisplay object + iconsDisplay[menu.title] = []; + // if social exists, add the icon name to the array menu.children.forEach(({ name, href }) => { if (name) { if (iconMap[name.toLowerCase() as keyof typeof iconMap]) { const Icon = iconMap[name.toLowerCase() as keyof typeof iconMap]; - if ( - menu.title === "Socials" - ) { - icons2Display.push( - ( - - - - ), - ); - } else { - // push the icon, add alt text for link - iconsDisplay.push( - ( - - - - ), - ); - } + iconsDisplay[menu.title].push( + ( + + + + ), + ); + + console.log(iconsDisplay[menu.title]); // remove the social from the list menu menu.children = menu.children.filter((child) => { @@ -163,6 +151,7 @@ export default function Footer() { + {/* handle rest of entries */} {menus.map((item) => (
{item.title}
@@ -181,33 +170,24 @@ export default function Footer() {
))} -
-
Find my projects here!
-
- {/* display array */} - {iconsDisplay.map((icon) => { - return ( -
- {icon} -
- ); - })} -
-
- -
-
Socials
-
- {/* display array */} - {icons2Display.map((icon) => { - return ( + {/* Handle apps with icons */} + {Object.entries(iconsDisplay).map(([title, item]) => ( +
+ {/*
{title}
*/} +
+
+

{title}

+
+
+
+ {Object.entries(item).map(([child, Icon]) => (
- {icon} + {Icon}
- ); - })} + ))} +
-
+ ))}
-- 2.45.2