From 00fe9ef304a78379adb6cf1459df289637955643 Mon Sep 17 00:00:00 2001 From: Chrono Date: Sat, 4 May 2024 19:37:06 -0400 Subject: [PATCH] update footer --- components/Footer/Footer.tsx | 102 ++++++++++++++++++++++++++++------- 1 file changed, 83 insertions(+), 19 deletions(-) diff --git a/components/Footer/Footer.tsx b/components/Footer/Footer.tsx index 510f89b..a10fc6e 100644 --- a/components/Footer/Footer.tsx +++ b/components/Footer/Footer.tsx @@ -1,23 +1,97 @@ -import BrandGithub from "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/brand-github.tsx"; +import BrandGitHub from "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/brand-github.tsx"; +import BrandGitLab from "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/brand-gitlab.tsx"; import BrandTwitter from "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/brand-twitter.tsx"; +import BrandTwitch from "https://deno.land/x/tabler_icons_tsx@0.0.6/tsx/brand-twitch.tsx"; + import SplashTextDisplay from "../../islands/SplashTextDisplay.tsx"; +import { JSX } from "preact/jsx-runtime"; + +const iconMap: { + [key: string]: (props: { + size: number; + }) => JSX.Element; +} = { + github: BrandGitHub, + gitlab: BrandGitLab, + twitter: BrandTwitter, + twitch: BrandTwitch, +}; export default function Footer() { - const menus = [ + let menus = [ { title: "Find my projects here!", children: [ - { name: "sourcehut", href: "https://sr.ht/~chrono/" }, + { name: "GitLab", href: "https://gitlab.com/Chrono-byte" }, { name: "GitHub", href: "https://github.com/Chrono-byte" }, + { name: "sourcehut", href: "https://sr.ht/~chrono/" }, ], }, { title: "Socials", children: [ { name: "Twitch", href: "https://twitch.tv/chronobyte_" }, + { name: "Twitter", href: "https://twitter.com/chronobyte_" }, ], }, ]; + const iconsDisplay: JSX.Element[] = []; + + // only display the socials that are enabled + const enabledSocials: string[] = [ + "gitlab", + // "sourcehut", + "github", + "twitch", + "twitter", + ]; + + menus.forEach((menu) => { + // filter out the socials that are not enabled + menu.children = menu.children.filter((child) => { + return enabledSocials.includes(child.name.toLocaleLowerCase()); + }); + + // sort the socials + menu.children.sort((a, b) => { + return b.name.localeCompare(a.name); + }); + + // if social exists, add the icon name to the array + menu.children.forEach((child) => { + if (iconMap[child.name.toLowerCase()]) { + const Icon = iconMap[child.name.toLowerCase()]; + + // push the icon add alt text for link + iconsDisplay.push( + ( + + + + ), + ); + + // trim the child out of the menu + menu.children = menu.children.filter((item) => { + return item !== child; + }); + } + }); + }); + + // shake out empty menus + menus = menus.filter((menu) => { + return menu.children.length > 0; + }); + + // sort the menus + menus.sort((a, b) => { + return a.title.localeCompare(b.title); + }); return (
@@ -29,8 +103,6 @@ export default function Footer() {
- Chrono -
@@ -59,20 +131,12 @@ export default function Footer() { All right reserved. - - - - +
+ {/* display array */} + {iconsDisplay.map((icon) => { + return icon; + })} +
-- 2.45.2