From 1180e9c8aad7887d99804b70265dd324ed19b075 Mon Sep 17 00:00:00 2001 From: Rainnny7 Date: Tue, 10 Sep 2024 16:25:39 -0400 Subject: [PATCH] Better support with Tether --- bun.lockb | Bin 204047 -> 204047 bytes package.json | 2 +- src/components/landing/discord-status.tsx | 136 +++++++++++----------- 3 files changed, 67 insertions(+), 71 deletions(-) diff --git a/bun.lockb b/bun.lockb index 8c04be3e455dd940c56c6b439da18bf4f2965f5f..a314c22b8133e96ee6b15823334f3affa04f6a2e 100644 GIT binary patch delta 150 zcmV;H0BQe^x(tuH43I7$_P{*jM8!hc-%s9%U8BZ0Ze+w8;CKk`S=4Pyt%aIxu}-=l zlL#d+vp68tn?UE+a5~w56=Z+G_ZktLmhBeDJP*i9U9sB`yLagIWG8Mv9VHYr)))Gn zhP~a$5;#{XWWsz(Bx5Nh2L#ij!svrdythrf0nSec0bVgKFfK8-A`Ak2Z2>a3pLqgs EqdIRxI{*Lx delta 150 zcmV;H0BQe^x(tuH43I7$a3`8-hB*@3RxbR=NN_`^hYAEsB!?L8?y655S@}W1u}-=l zlgK(Svp68tn?N#?4F|E)oG}+K| z-U1pLqgs Eqbq|#SpWb4 diff --git a/package.json b/package.json index 7bd55d6..4e80286 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "sharp": "^0.33.5", "tailwind-merge": "^2.5.2", "tailwindcss-animate": "^1.0.7", - "use-tether": "^1.0.0" + "use-tether": "^1.0.2" }, "devDependencies": { "typescript": "^5", diff --git a/src/components/landing/discord-status.tsx b/src/components/landing/discord-status.tsx index 1863041..c877f5f 100644 --- a/src/components/landing/discord-status.tsx +++ b/src/components/landing/discord-status.tsx @@ -1,7 +1,12 @@ "use client"; import { ReactElement, useEffect, useState } from "react"; -import { DiscordUser, SpotifyActivity, useTetherWS } from "use-tether"; +import { + DiscordUser, + SpotifyActivity, + UserBadge, + useTetherWS, +} from "use-tether"; import Image from "next/image"; import { cn, truncateText } from "@/lib/utils"; import SimpleTooltip from "@/components/ui/simple-tooltip"; @@ -15,31 +20,6 @@ const statusColors = { OFFLINE: "bg-zinc-500", }; -const userBadges = { - // Nitro - "https://cdn.discordapp.com/badge-icons/2ba85e8026a8614b640c2837bcdfe21b.png": - { - name: "Nitro Subscriber", - predicate: (discordUser: DiscordUser) => true, // TODO: Add Nitro predicate - }, - - // Early Supporter - "https://cdn.discordapp.com/badge-icons/7060786766c9c840eb3019e725d2b358.png": - { - name: "Early Supporter", - predicate: (discordUser: DiscordUser) => - discordUser.flags.list.includes("EARLY_SUPPORTER"), - }, - - // Active Developer - "https://cdn.discordapp.com/badge-icons/6bdc42827a38498929a4920da12695d9.png": - { - name: "Active Developer", - predicate: (discordUser: DiscordUser) => - discordUser.flags.list.includes("ACTIVE_DEVELOPER"), - }, -}; - const DiscordStatus = (): ReactElement | undefined => { const discordUser: DiscordUser | undefined = useTetherWS("504147739131641857"); @@ -49,14 +29,14 @@ const DiscordStatus = (): ReactElement | undefined => { return (
- +
- {/* TODO: Add bio */} + {discordUser.bio && }
-
+
{/* Activity */} @@ -74,34 +54,47 @@ const DiscordStatus = (): ReactElement | undefined => { ); }; -const BannerAvatar = ({ user }: { user: DiscordUser }): ReactElement => ( -
- {user.banner && ( - {`${user.username}'s - )} -
- {`${user.username}'s -
+const BannerAvatar = ({ + discordUser, +}: { + discordUser: DiscordUser; +}): ReactElement => { + const bannerClasses = + "border-2 border-zinc-300 dark:border-zinc-900 rounded-t-xl"; + return ( +
+ {discordUser.banner ? ( + {`${discordUser.username}'s + ) : ( +
+ )} +
+ {`${discordUser.username}'s +
+
-
-); + ); +}; const Bio = ({ bio }: { bio: string }): ReactElement => ( @@ -116,20 +109,23 @@ const Badges = ({ }: { discordUser: DiscordUser; }): ReactElement => ( -
- {Object.entries(userBadges) - .filter(([_, badge]) => badge.predicate(discordUser)) - .map(([badgeIcon, badge], index) => ( - - Discord Profile Badge - - ))} +
4 && "max-w-[4.75rem]" + )} + > + {discordUser.badges.map((badge: UserBadge, index: number) => ( + + Discord Profile Badge + + ))}
);