Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add donor and contributor cards in vencord settings #3049

Open
wants to merge 12 commits into
base: dev
Choose a base branch
from
10 changes: 7 additions & 3 deletions src/components/DonateButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@ import { Button } from "@webpack/common";

import { Heart } from "./Heart";

export default function DonateButton(props: any) {
export default function DonateButton({
look = Button.Looks.LINK,
color = Button.Colors.TRANSPARENT,
...props
}) {
return (
<Button
{...props}
look={Button.Looks.LINK}
color={Button.Colors.TRANSPARENT}
look={look}
color={color}
onClick={() => VencordNative.native.openExternal("https://github.com/sponsors/Vendicated")}
>
<Heart />
Expand Down
91 changes: 91 additions & 0 deletions src/components/VencordSettings/SpecialCard.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* 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 <https://www.gnu.org/licenses/>.
*/

import "./specialCard.css";

import { classNameFactory } from "@api/Styles";
import { Card, Forms, React } from "@webpack/common";
import type { PropsWithChildren } from "react";

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, children }: PropsWithChildren<StyledCardProps>) {
const cardStyle: React.CSSProperties = {
backgroundColor: backgroundColor || "#9c85ef",
backgroundImage: `url(${backgroundImage || ""})`,
};

return (
<Card
className={cl("card", "card-special")}
style={cardStyle}
>
<div className={cl("card-flex")}>
<div className={cl("card-flex-main")}>
<Forms.FormTitle className={cl("title")} tag="h5">{title}</Forms.FormTitle>
<Forms.FormText className={cl("subtitle")}>{subtitle}</Forms.FormText>
<Forms.FormText className={cl("text")}>
{description.split("\n").map((line, index) => (
<React.Fragment key={index}>
{line}
<br />
</React.Fragment>
))}
</Forms.FormText>

{children}
</div>
{
cardImage && (
<>
<div className={cl("image-container")}>
<img
role="presentation"
src={cardImage}
alt=""
className={cl("image")}
/>
</div>
</>
)
}
</div>
{
buttonTitle && (
<>
<Forms.FormDivider className={cl("seperator")} />
<Forms.FormText className={cl("hyperlink")} onClick={onClick} >
{buttonTitle}
</Forms.FormText>
</>
)
}
</Card>
);
}
96 changes: 69 additions & 27 deletions src/components/VencordSettings/VencordTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,39 @@ 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, 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";

const DONATOR_BACKGROUND_IMAGE = "https://media.discordapp.net/stickers/1311070116305436712.png?size=2048";
const CONTRIB_BACKGROUND_IMAGE = "https://media.discordapp.net/stickers/1311070166481895484.png?size=2048";

type KeysOfType<Object, Type> = {
[K in keyof Object]: Object[K] extends Type ? K : never;
}[keyof Object];


function VencordSettings() {
const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, {
fallbackValue: "Loading..."
Expand All @@ -55,6 +65,8 @@ function VencordSettings() {
const isMac = navigator.platform.toLowerCase().startsWith("mac");
const needsVibrancySettings = IS_DISCORD_DESKTOP && isMac;

const user = UserStore.getCurrentUser();

const Switches: Array<false | {
key: KeysOfType<typeof settings, boolean>;
title: string;
Expand Down Expand Up @@ -99,7 +111,49 @@ function VencordSettings() {

return (
<SettingsTab title="Vencord Settings">
<DonateCard image={donateImage} />
{
isDonor(user?.id)
?
<SpecialCard
title="Donations"
subtitle="Thank you for donating!"
description={"People will be able to see your requested badge through Vencord, and you're able to request to change it any time.\n\nDon't worry about your perks running out if you stop your subscription, you'll keep your perks forever!"}
cardImage={VENNIE_DONATOR_IMAGE}
backgroundImage={DONATOR_BACKGROUND_IMAGE}
backgroundColor="#ED87A9"
>
{
DonateButtonComponent()
}
</SpecialCard>
:
<SpecialCard
title="Support the Project"
description={"Please consider supporting the development of Vencord by donating!"}
cardImage={donateImage}
backgroundImage={DONATOR_BACKGROUND_IMAGE}
backgroundColor="#c3a3ce"
>
{
DonateButtonComponent()
}
</SpecialCard>
}
{
isPluginDev(user?.id)
&&
<SpecialCard
title="Contributions"
subtitle="Thank you for contributing!"
description={"Since you've contributed to Vencord and added yourself to contributors list, you now have a cool new badge!\n\nTo avoid unwanted DMs from people you don't know, a warning has been placed on your profile not to message you for support."}
cardImage={COZY_CONTRIB_IMAGE}
backgroundImage={CONTRIB_BACKGROUND_IMAGE}
backgroundColor="#EDCC87"
buttonTitle="See What You Contributed To"
buttonOnClick={() => openContributorModal(user)}
/>
}

<Forms.FormSection title="Quick Actions">
<QuickActionCard>
<QuickAction
Expand Down Expand Up @@ -239,31 +293,19 @@ function VencordSettings() {
);
}

interface DonateCardProps {
image: string;
}

function DonateCard({ image }: DonateCardProps) {
function DonateButtonComponent() {
return (
<Card className={cl("card", "donate")}>
<div>
<Forms.FormTitle tag="h5">Support the Project</Forms.FormTitle>
<Forms.FormText>Please consider supporting the development of Vencord by donating!</Forms.FormText>
<DonateButton style={{ transform: "translateX(-1em)" }} />
</div>
<img
role="presentation"
src={image}
alt=""
height={128}
style={{
imageRendering: image === SHIGGY_DONATE_IMAGE ? "pixelated" : void 0,
marginLeft: "auto",
transform: image === DEFAULT_DONATE_IMAGE ? "rotate(10deg)" : void 0
}}
/>
</Card>
<DonateButton
look={Button.Looks.FILLED}
color={Button.Colors.WHITE}
style={{ marginTop: "1em" }}
/>
);
}

function isDonor(userId: string): boolean {
const donorBadges = (Plugins.BadgeAPI as unknown as typeof import("../../plugins/_api/badges").default).getDonorBadges(userId);
return GuildMemberStore.getMember(VENCORD_GUILD_ID, userId)?.roles.includes(DONOR_ROLE_ID) || !!donorBadges;
}

export default wrapTab(VencordSettings, "Vencord Settings");
2 changes: 1 addition & 1 deletion src/components/VencordSettings/addonCard.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@
.vc-addon-title:hover {
overflow: visible;
animation: vc-addon-title var(--duration) linear infinite;
}
}
21 changes: 15 additions & 6 deletions src/components/VencordSettings/quickActions.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,34 @@
.vc-settings-quickActions-card {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, max-content));
grid-template-columns: repeat(3, 1fr);
gap: 0.5em;
justify-content: center;
padding: 0.5em 0;
padding: 0.5em;
margin-bottom: 1em;
}

@media (width <=1040px) {
.vc-settings-quickActions-card {
grid-template-columns: repeat(2, 1fr);
}
}

.vc-settings-quickActions-pill {
all: unset;
background: var(--background-secondary);
color: var(--header-secondary);
display: flex;
align-items: center;
gap: 0.5em;
padding: 8px 12px;
border-radius: 9999px;
padding: 8px 9px;
border-radius: 6px;
transition: 0.1s ease-out;
box-sizing: border-box;
}

.vc-settings-quickActions-pill:hover {
background: var(--background-secondary-alt);
transform: translateY(-1px);
box-shadow: var(--elevation-high);
}

.vc-settings-quickActions-pill:focus-visible {
Expand All @@ -30,4 +39,4 @@
.vc-settings-quickActions-img {
width: 24px;
height: 24px;
}
}
68 changes: 68 additions & 0 deletions src/components/VencordSettings/specialCard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
.vc-settings-card {
padding: 1em;
margin-bottom: 1em;
}

.vc-special-card-special {
padding: 1.9em;
margin-bottom: 1em;
background-size: cover;
background-position: center;
}

.vc-special-card-flex {
display: flex;
flex-direction: row;
}

.vc-special-card-flex-main {
width: 100%;
}

.vc-special-title {
color: black;
}

.vc-special-subtitle {
color: black;
font-size: 1.4em;
font-weight: bold;
margin-top: 0.9em;
}

.vc-special-text {
color: black;
font-size: 1em;
margin-top: 1em;
}

.vc-special-seperator {
margin-top: 1em;
border-top: '1px solid white';
opacity: 0.4;
}

.vc-special-hyperlink {
color: black;
font-size: 1em;
font-weight: bold;
margin-top: 1em;
text-align: center;
cursor: pointer;
}

.vc-special-image-container {
display: flex;
justify-content: center;
align-items: center;
margin-left: 1em;
flex-shrink: 0;
width: 100px;
height: 100px;
border-radius: 50%;
background-color: white;
}

.vc-special-image {
width: 65%;
}
Loading