diff --git a/bun.lockb b/bun.lockb index 59c8efb..3cc22d8 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 376e21d..325b1c6 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,7 @@ "@radix-ui/react-scroll-area": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-tooltip": "^1.1.2", + "axios": "^1.7.7", "class-variance-authority": "^0.7.0", "clsx": "^2.1.1", "framer-motion": "^11.3.30", diff --git a/public/me.png b/public/me.png index 4e8093e..bb02a87 100644 Binary files a/public/me.png and b/public/me.png differ diff --git a/src/app/(pages)/page.tsx b/src/app/(pages)/page.tsx index 07eefbf..7a021af 100644 --- a/src/app/(pages)/page.tsx +++ b/src/app/(pages)/page.tsx @@ -19,7 +19,9 @@ const LandingPage = (): ReactElement => ( - + + + ); diff --git a/src/components/landing/discord-status.tsx b/src/components/landing/discord-status.tsx index 9c074e7..6359788 100644 --- a/src/components/landing/discord-status.tsx +++ b/src/components/landing/discord-status.tsx @@ -1,89 +1,152 @@ "use client"; -import { ReactElement } from "react"; -import { Activity, Data, DiscordUser, useLanyardWS } from "use-lanyard"; -import BlurFade from "@/components/ui/blur-fade"; +import { ReactElement, useEffect, useState } from "react"; +import { Data, DiscordUser, useLanyardWS } from "use-lanyard"; +import DCDNUser from "@/types/dcdn"; +import axios from "axios"; import Image from "next/image"; import { cn } from "@/lib/utils"; -import { PlayIcon } from "@heroicons/react/24/outline"; const statusColors = { online: "bg-green-500", idle: "bg-yellow-500", dnd: "bg-red-500", + offline: "bg-zinc-500", }; -const DiscordStatus = (): ReactElement => { +const userBadges = { + // Nitro + "https://cdn.discordapp.com/badge-icons/2ba85e8026a8614b640c2837bcdfe21b.png": + (dcdnUser: DCDNUser) => dcdnUser.premiumType, + + // Early Supporter + "https://cdn.discordapp.com/badge-icons/7060786766c9c840eb3019e725d2b358.png": + (dcdnUser: DCDNUser) => (dcdnUser.flags & (1 << 9)) === 1 << 9, + + // Active Developer + "https://cdn.discordapp.com/badge-icons/6bdc42827a38498929a4920da12695d9.png": + (dcdnUser: DCDNUser) => (dcdnUser.flags & (1 << 22)) === 1 << 22, +}; + +const DiscordStatus = (): ReactElement | undefined => { + // Data from Lanyard const discordData: Data | undefined = useLanyardWS("504147739131641857"); const discordUser: DiscordUser | undefined = discordData?.discord_user; + + // Some data isn't provided by Lanyard, use DCDN for more + const [dcdnUser, setDCDNUser] = useState(undefined); + + // When the data changes, update the DCDN user + useEffect(() => { + if (!discordUser) { + return; + } + axios + .get(`https://dcdn.dstn.to/profile/${discordUser.id}`) + .then((res) => + setDCDNUser({ + premiumType: res.data.premium_type, + ...res.data.user, + }) + ); + }, [discordData]); + + // Missing required data + if (!discordData || !discordUser || !dcdnUser) { + return undefined; + } + return ( -
- {discordData && discordUser && ( - - {/* Avatar & Status */} -
- {`${discordUser.username}'s - {discordData.discord_status !== "offline" && ( -
- )} -
+
+
+ - {/* Username & Basic Activity */} -
-
-

- {discordUser.display_name} -

-

- {discordUser.username} -

-
- - {discordData.activities.length > 0 && ( - - )} +
+
+ {dcdnUser.bio && } +
- - )} +
+ +
+
+
); }; -const BasicActivityDisplay = ({ - activity, +const BannerAvatar = ({ + discordData, + discordUser, + dcdnUser, }: { - activity: Activity; -}): ReactElement => { - const prefix = - activity.type === 0 - ? "Playing" - : activity.type === 1 - ? "Streaming" - : "Listening to"; - - return ( -
- {prefix} {activity.name}{" "} - + discordData: Data; + discordUser: DiscordUser; + dcdnUser: DCDNUser; +}): ReactElement => ( +
+ {`${discordUser.username}'s +
+ {`${discordUser.username}'s +
- ); -}; +
+); + +const Bio = ({ dcdnUser }: { dcdnUser: DCDNUser }): ReactElement => ( +
+ {dcdnUser.bio} +
+); + +const Badges = ({ dcdnUser }: { dcdnUser: DCDNUser }): ReactElement => ( +
+ {Object.entries(userBadges) + .filter(([_, predicate]) => predicate(dcdnUser)) + .map(([badge], index) => ( + Discord Profile Badge + ))} +
+); + +const Username = ({ + discordUser, +}: { + discordUser: DiscordUser; +}): ReactElement => ( +
+

+ {discordUser.global_name} +

+

{discordUser.username}

+
+); export default DiscordStatus; diff --git a/src/components/landing/nav-content/my-work.tsx b/src/components/landing/nav-content/my-work.tsx index 6617cd9..7aa98e1 100644 --- a/src/components/landing/nav-content/my-work.tsx +++ b/src/components/landing/nav-content/my-work.tsx @@ -74,7 +74,7 @@ const MyWork = (): ReactElement => { target="_blank" > ( {skillset.map((skill, index) => ( diff --git a/src/components/landing/navbar.tsx b/src/components/landing/navbar.tsx index 7cd61cc..4fff87a 100644 --- a/src/components/landing/navbar.tsx +++ b/src/components/landing/navbar.tsx @@ -33,7 +33,7 @@ const Navbar = (): ReactElement => ( const Branding = (): ReactElement => ( (
{/* Git */} - @@ -100,7 +100,7 @@ const UsefulLinksContent = (): ReactElement => ( {/* Wiki */} - @@ -108,7 +108,7 @@ const UsefulLinksContent = (): ReactElement => ( {/* Status Page */} - diff --git a/src/components/landing/navigation.tsx b/src/components/landing/navigation.tsx index 571606f..417ac71 100644 --- a/src/components/landing/navigation.tsx +++ b/src/components/landing/navigation.tsx @@ -46,7 +46,7 @@ const Navigation = (): ReactElement => {