From 661a0157a8a83e9b64c9fcdb16e844e00f80a8c0 Mon Sep 17 00:00:00 2001 From: khcrysalis <97859147+khcrysalis@users.noreply.github.com> Date: Thu, 21 Nov 2024 16:01:48 -0800 Subject: [PATCH] feat: donator & contributor cards in settings --- .../VencordSettings/SpecialCard.tsx | 86 +++++++++++++++++++ src/components/VencordSettings/VencordTab.tsx | 44 +++++++++- src/components/VencordSettings/addonCard.css | 2 +- .../VencordSettings/quickActions.css | 21 +++-- .../VencordSettings/specialCard.css | 69 +++++++++++++++ src/plugins/_core/supportHelper.tsx | 8 +- src/utils/constants.ts | 9 ++ 7 files changed, 223 insertions(+), 16 deletions(-) create mode 100644 src/components/VencordSettings/SpecialCard.tsx create mode 100644 src/components/VencordSettings/specialCard.css diff --git a/src/components/VencordSettings/SpecialCard.tsx b/src/components/VencordSettings/SpecialCard.tsx new file mode 100644 index 000000000..c36a2d839 --- /dev/null +++ b/src/components/VencordSettings/SpecialCard.tsx @@ -0,0 +1,86 @@ +/* + * Vencord, a modification for Discord's desktop app + * Copyright (c) 2023 Vendicated and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . +*/ + +import "./specialCard.css"; + +import { classNameFactory } from "@api/Styles"; +import { Card, Forms, React } from "@webpack/common"; + +const cl = classNameFactory("vc-special-"); + +interface StyledCardProps { + title: string; + subtitle: string; + description: string; + cardImage?: string; + backgroundImage?: string; + backgroundColor?: string; + buttonTitle?: string; + buttonOnClick?: () => void; +} + +export function SpecialCard({ title, subtitle, description, cardImage, backgroundImage, backgroundColor, buttonTitle, buttonOnClick: onClick }: StyledCardProps) { + const cardStyle: React.CSSProperties = { + backgroundColor: backgroundColor || "#9c85ef", + backgroundImage: `url(${backgroundImage || ""})`, + }; + + return ( + +
+
+ + {title} + + + {subtitle} + + + {description.split("\n").map((line, index) => ( + + {line} +
+
+ ))} +
+
+
+ +
+
+ { + buttonTitle && ( + <> + + + {buttonTitle} + + + ) + } +
+ ); +} diff --git a/src/components/VencordSettings/VencordTab.tsx b/src/components/VencordSettings/VencordTab.tsx index 97f82e777..b87d6286d 100644 --- a/src/components/VencordSettings/VencordTab.tsx +++ b/src/components/VencordSettings/VencordTab.tsx @@ -20,29 +20,35 @@ import { openNotificationLogModal } from "@api/Notifications/notificationLog"; import { useSettings } from "@api/Settings"; import { classNameFactory } from "@api/Styles"; import DonateButton from "@components/DonateButton"; +import { openContributorModal } from "@components/PluginSettings/ContributorModal"; import { openPluginModal } from "@components/PluginSettings/PluginModal"; import { gitRemote } from "@shared/vencordUserAgent"; +import { DONOR_ROLE_ID, VENCORD_GUILD_ID } from "@utils/constants"; import { Margins } from "@utils/margins"; -import { identity } from "@utils/misc"; +import { identity, isPluginDev } from "@utils/misc"; import { relaunch, showItemInFolder } from "@utils/native"; import { useAwaiter } from "@utils/react"; -import { Button, Card, Forms, React, Select, Switch } from "@webpack/common"; +import { Button, Card, Forms, GuildMemberStore, React, Select, Switch, UserStore } from "@webpack/common"; + +import Plugins from "~plugins"; import { Flex, FolderIcon, GithubIcon, LogIcon, PaintbrushIcon, RestartIcon } from ".."; import { openNotificationSettingsModal } from "./NotificationSettings"; import { QuickAction, QuickActionCard } from "./quickActions"; import { SettingsTab, wrapTab } from "./shared"; +import { SpecialCard } from "./SpecialCard"; const cl = classNameFactory("vc-settings-"); const DEFAULT_DONATE_IMAGE = "https://cdn.discordapp.com/emojis/1026533090627174460.png"; const SHIGGY_DONATE_IMAGE = "https://media.discordapp.net/stickers/1039992459209490513.png"; +const VENNIE_DONATOR_IMAGE = "https://cdn.discordapp.com/emojis/1238120638020063377.png"; +const COZY_CONTRIB_IMAGE = "https://cdn.discordapp.com/emojis/1026533070955872337.png"; type KeysOfType = { [K in keyof Object]: Object[K] extends Type ? K : never; }[keyof Object]; - function VencordSettings() { const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, { fallbackValue: "Loading..." @@ -55,6 +61,8 @@ function VencordSettings() { const isMac = navigator.platform.toLowerCase().startsWith("mac"); const needsVibrancySettings = IS_DISCORD_DESKTOP && isMac; + const user = UserStore.getCurrentUser(); + const Switches: Array; title: string; @@ -99,7 +107,30 @@ function VencordSettings() { return ( - + { + isDonor(user?.id) ? : + } + { + isPluginDev(user?.id) + && openContributorModal(user)} + /> + } + ); // iife so #__PURE__ works correctly