From 1108495507ce0a43b032bb90992a54b4da0b87fa Mon Sep 17 00:00:00 2001 From: Xevion Date: Mon, 26 Dec 2022 11:08:10 -0600 Subject: [PATCH] Add mobile-only link button, Adjust mobile text sizing, adjust link/click event handling --- src/components/ItemCard.tsx | 86 ++++++++++++++++++++++--------------- src/pages/index.tsx | 2 +- 2 files changed, 52 insertions(+), 36 deletions(-) diff --git a/src/components/ItemCard.tsx b/src/components/ItemCard.tsx index 3c7ce2d..7302ae2 100644 --- a/src/components/ItemCard.tsx +++ b/src/components/ItemCard.tsx @@ -19,49 +19,65 @@ type ItemCardProps = { const ItemCard = ({banner, bannerBlur, title, description, links, location}: ItemCardProps) => { const itemRef = useRef(null); + const mobileButtonRef = useRef(null); const [active, toggleActive, setActive] = useToggle() const router = useRouter(); - useOnClickOutside(itemRef, () => { - setActive(false); + useOnClickOutside(itemRef, (event) => { + if (mobileButtonRef.current != null && mobileButtonRef.current?.contains(event.target as Node)) + return; + else + setActive(false); }) - // TODO: Add mobile-only button when tapped showing button link for project page + const navigate = () => { + if (!isHoverable()) toggleActive(); + else { + router.push(location); + } + } - return
{ - if (!isHoverable()) toggleActive(); - else { - router.push(location); - } - }}> - classNames("object-cover", loaded ? null : "blur-xl")} - placeholder="blur" - alt={`Banner for ${title}`} - /> -
- - -
{title}
-
- {description} -
- - {(links?.length ?? 0) > 0 ? -
-
- {links!.map(({icon, location, newTab}) => - - {LinkIcons[icon]!({})} - )} + return <> +
+ classNames("object-cover", loaded ? null : "blur-xl")} + placeholder="blur" + alt={`Banner for ${title}`} + /> +
+
+ {title} +
+ {description}
-
: null} +
+ {(links?.length ?? 0) > 0 ? +
+
+ {links!.map(({icon, location, newTab}) => + + {LinkIcons[icon]!({})} + )} +
+
: null} +
+
-
+ {active ? + + Learn More + + : null} + } export default ItemCard; \ No newline at end of file diff --git a/src/pages/index.tsx b/src/pages/index.tsx index cfb2ab2..56373f7 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -102,7 +102,7 @@ const Home: NextPage = ({projects}: HomeStaticProps) => {
-
+
{ projects.map((project, index) =>