From a29c6e41a6334c3b4ac7b2ff8122a4173edecbd3 Mon Sep 17 00:00:00 2001 From: John Paul Larkin <107807466+John-Paul-Larkin@users.noreply.github.com> Date: Thu, 24 Oct 2024 11:35:48 +0100 Subject: [PATCH] add focusable HOC --- components/Focusable/Focusable.tsx | 13 +++++++ components/Footer/Footer.tsx | 55 +++++++++++++++++------------- 2 files changed, 44 insertions(+), 24 deletions(-) create mode 100644 components/Focusable/Focusable.tsx diff --git a/components/Focusable/Focusable.tsx b/components/Focusable/Focusable.tsx new file mode 100644 index 00000000..9d6b93ba --- /dev/null +++ b/components/Focusable/Focusable.tsx @@ -0,0 +1,13 @@ +import React, { cloneElement, ReactElement } from "react"; + +interface FocusableProps { + children: ReactElement; +} + +const Focusable: React.FC = ({ children }) => { + return cloneElement(children, { + className: `${children.props.className} rounded-md focus:outline-none focus:ring-white focus-visible:ring-2 focus-visible:ring-pink-600 focus-visible:ring-offset-pink-600`, + }); +}; + +export default Focusable; diff --git a/components/Footer/Footer.tsx b/components/Footer/Footer.tsx index ec34e146..9fc3d970 100644 --- a/components/Footer/Footer.tsx +++ b/components/Footer/Footer.tsx @@ -13,6 +13,7 @@ import { twitterUrl, youtubeUrl, } from "../../config/site_settings"; +import Focusable from "../Focusable/Focusable"; const navigation = { main: footerNav, @@ -55,37 +56,43 @@ const Footer = () => { {navigation.main.map((item) => (
{item.href.includes("http") ? ( - - {item.name} - + + + {item.name} + + ) : ( - - {item.name} - + + + {item.name} + + )}
))}
{navigation.social.map((item) => ( - - {item.name} - + + + {item.name} + + ))}