From 3c16258b8e0ebafc9991e6ba8d2c74849e023195 Mon Sep 17 00:00:00 2001 From: Xevion Date: Sun, 25 Dec 2022 21:32:37 -0600 Subject: [PATCH] Add links to icons --- src/components/ItemCard.tsx | 25 ++++++++-------- src/pages/index.tsx | 57 +++++++++++++++++++++++++++++-------- src/styles/globals.scss | 6 +++- 3 files changed, 63 insertions(+), 25 deletions(-) diff --git a/src/components/ItemCard.tsx b/src/components/ItemCard.tsx index a75e454..140b69f 100644 --- a/src/components/ItemCard.tsx +++ b/src/components/ItemCard.tsx @@ -4,17 +4,18 @@ import {classNames, isHoverable} from "../utils/helpers"; import DependentImage from "./DependentImage"; import ReactMarkdown from 'react-markdown' -import {AiFillGithub, AiFillLinkedin, AiOutlineLink,} from "react-icons/ai"; -import {RxOpenInNewWindow} from "react-icons/rx"; +import Link from "next/link"; +import {LinkIcon, LinkIcons} from "../pages"; type ItemCardProps = { banner: string; bannerBlur: string; title: string; description: string; + links?: LinkIcon[]; } -const ItemCard = ({banner, bannerBlur, title, description}: ItemCardProps) => { +const ItemCard = ({banner, bannerBlur, title, description, links}: ItemCardProps) => { const itemRef = useRef(null); const [active, toggleActive, setActive] = useToggle() @@ -34,20 +35,20 @@ const ItemCard = ({banner, bannerBlur, title, description}: ItemCardProps) => { />
-
{title}
+
{title}
{description}
-
-
- - {/**/} - - {/**/} + { (links?.length ?? 0) > 0 ?
+
+ {links!.map(({icon, location}) => { + return + {LinkIcons[icon]({})} + + })}
-
+
: null}
} diff --git a/src/pages/index.tsx b/src/pages/index.tsx index 3ffdf8d..89655e0 100644 --- a/src/pages/index.tsx +++ b/src/pages/index.tsx @@ -4,12 +4,29 @@ import React, {useEffect} from "react"; import ItemCard from "../components/ItemCard"; import {getPlaiceholder} from "plaiceholder"; import {useBreakpointValue} from "../utils/helpers"; +import {IconType} from "react-icons"; +import {AiFillGithub, AiOutlineLink} from "react-icons/ai"; +import {RxOpenInNewWindow} from "react-icons/rx"; -interface Project { +export type Project = { title: string; banner: string; longDescription: string; shortDescription: string; + links?: LinkIcon[]; +} + +export type LinkIconType = "github" | "external" | "link"; + +export const LinkIcons: Record = { + github: AiFillGithub, + external: RxOpenInNewWindow, + link: AiOutlineLink +} + +export type LinkIcon = { + icon: LinkIconType; + location: string; } type ProjectWithBlur = Project & { bannerBlur: string }; @@ -20,31 +37,47 @@ type HomeStaticProps = { } export async function getStaticProps(context: GetStaticPropsContext) { - const projects = [ + const projects: Project[] = [ { title: "Phototag", banner: "/phototag.png", longDescription: `Using Google's Vision API and supporting metadata formats on Windows, Phototag makes it easy to quickly add rich, descriptive tags to your photos, saving you time and effort.`, - shortDescription: "Effortlessly add rich & descriptive tags to your photos with Phototag." + shortDescription: "Effortlessly add rich & descriptive tags to your photos with Phototag.", + links: [ + { + icon: "github", + location: "https://github.com/Xevion/phototag" + }, + { + icon: "external", + location: "https://github.com/Xevion/phototag" + } + ] }, { title: "Paths", banner: "/paths.png", shortDescription: "Discover the power of graph traversal algorithms with my interactive application.", longDescription: `Discover the power of graph traversal algorithms with my interactive Unity application! - Easily generate and edit graphs, create mazes, and experiment with different algorithm configurations to find the most efficient path.` + Easily generate and edit graphs, create mazes, and experiment with different algorithm configurations to find the most efficient path.`, + links: [ + { + icon: "github", + location: "https://github.com/Xevion/Paths" + } + ] } - ].map(async project => { - const {base64} = await getPlaiceholder(project.banner, {size: 16}); - return { - ...project, - bannerBlur: base64 - }; - }) + ]; return { props: { - projects: await Promise.all(projects) + projects: await Promise.all(projects.map(async project => { + const {base64} = await getPlaiceholder(project.banner, {size: 16}); + return { + ...project, + bannerBlur: base64 + }; + })) } } } diff --git a/src/styles/globals.scss b/src/styles/globals.scss index ab178a8..4c995c6 100644 --- a/src/styles/globals.scss +++ b/src/styles/globals.scss @@ -53,7 +53,11 @@ html, body { .icon-grid { direction: rtl; - > svg { + > a > svg { + @apply w-full h-full; + } + + > svg, a { width: 75%; height: 75%; @apply transition-transform drop-shadow-md hover:scale-[120%] opacity-80 hover:opacity-100 text-white m-auto aspect-square;