diff --git a/src/api/settings.ts b/src/api/settings.ts
index 9e548009..b7c143a3 100644
--- a/src/api/settings.ts
+++ b/src/api/settings.ts
@@ -29,6 +29,7 @@ export interface Settings {
notifyAboutUpdates: boolean;
useQuickCss: boolean;
enableReactDevtools: boolean;
+ themeLinks: string[];
plugins: {
[plugin: string]: {
enabled: boolean;
@@ -40,6 +41,7 @@ export interface Settings {
const DefaultSettings: Settings = {
notifyAboutUpdates: true,
useQuickCss: true,
+ themeLinks: [],
enableReactDevtools: false,
plugins: {}
};
diff --git a/src/components/VencordSettings/ThemesTab.tsx b/src/components/VencordSettings/ThemesTab.tsx
new file mode 100644
index 00000000..60dd96d0
--- /dev/null
+++ b/src/components/VencordSettings/ThemesTab.tsx
@@ -0,0 +1,135 @@
+/*
+ * Vencord, a modification for Discord's desktop app
+ * Copyright (c) 2022 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 { useSettings } from "@api/settings";
+import ErrorBoundary from "@components/ErrorBoundary";
+import { Link } from "@components/Link";
+import { useAwaiter } from "@utils/misc";
+import { findLazy } from "@webpack";
+import { Card, Forms, Margins, React, TextArea } from "@webpack/common";
+
+const TextAreaProps = findLazy(m => typeof m.textarea === "string");
+
+function Validator({ link }: { link: string; }) {
+ const [res, err, pending] = useAwaiter(() => fetch(link).then(res => {
+ if (res.status > 300) throw `${res.status} ${res.statusText}`;
+ const contentType = res.headers.get("Content-Type");
+ if (!contentType?.startsWith("text/css") && !contentType?.startsWith("text/plain"))
+ throw "Not a CSS file. Remember to use the raw link!";
+
+ return "Okay!";
+ }));
+
+ const text = pending
+ ? "Checking..."
+ : err
+ ? `Error: ${err instanceof Error ? err.message : String(err)}`
+ : "Valid!";
+
+ return {text};
+}
+
+function Validators({ themeLinks }: { themeLinks: string[]; }) {
+ if (!themeLinks.length) return null;
+
+ return (
+ <>
+ Validator
+ This section will tell you whether your themes can successfully be loaded
+
+ >
+ );
+}
+
+export default ErrorBoundary.wrap(function () {
+ const settings = useSettings();
+ const ref = React.useRef();
+
+ function onBlur() {
+ settings.themeLinks = [...new Set(
+ ref.current!.value
+ .trim()
+ .split(/\n+/)
+ .map(s => s.trim())
+ .filter(Boolean)
+ )];
+ }
+
+ return (
+ <>
+
+ Paste links to .css / .theme.css files here
+ One link per line
+ Be careful to use the raw links or github.io links!
+
+ Find Themes:
+
+
+ BetterDiscord Themes
+
+ Github
+
+ If using the BD site, click on "Source" somewhere below the Download button
+ In the GitHub repository of your theme, find X.theme.css / X.css, click on it, then click the "Raw" button
+
+ If the theme has configuration that requires you to edit the file:
+
+
• Make a github account
+
• Click the fork button on the top right
+
• Edit the file
+
• Use the link to your own repository instead
+
+
+
+ Themes
+
+
+ >
+ );
+});
diff --git a/src/components/VencordSettings/index.tsx b/src/components/VencordSettings/index.tsx
index 37dab8f5..b49e4b49 100644
--- a/src/components/VencordSettings/index.tsx
+++ b/src/components/VencordSettings/index.tsx
@@ -24,6 +24,7 @@ import cssText from "~fileContent/settingsStyles.css";
import BackupRestoreTab from "./BackupRestoreTab";
import PluginsTab from "./PluginsTab";
+import ThemesTab from "./ThemesTab";
import Updater from "./Updater";
import VencordSettings from "./VencordTab";
@@ -47,7 +48,7 @@ interface SettingsTab {
const SettingsTabs: Record = {
VencordSettings: { name: "Vencord", component: () => },
VencordPlugins: { name: "Plugins", component: () => },
- VencordThemes: { name: "Themes", component: () => Coming soon to a Vencord near you! },
+ VencordThemes: { name: "Themes", component: () => },
VencordUpdater: { name: "Updater" }, // Only show updater if IS_WEB is false
VencordSettingsSync: { name: "Backup & Restore", component: () => },
};
diff --git a/src/utils/quickCss.ts b/src/utils/quickCss.ts
index 1f9f235f..de4eaefb 100644
--- a/src/utils/quickCss.ts
+++ b/src/utils/quickCss.ts
@@ -21,6 +21,7 @@ import { addSettingsListener, Settings } from "@api/settings";
import IpcEvents from "./IpcEvents";
let style: HTMLStyleElement;
+let themesStyle: HTMLStyleElement;
export async function toggle(isEnabled: boolean) {
if (!style) {
@@ -35,7 +36,22 @@ export async function toggle(isEnabled: boolean) {
style.disabled = !isEnabled;
}
+async function initThemes() {
+ if (!themesStyle) {
+ themesStyle = document.createElement("style");
+ themesStyle.id = "vencord-themes";
+ document.head.appendChild(themesStyle);
+ }
+
+ const { themeLinks } = Settings;
+ const links = themeLinks.map(link => `@import url("${link.trim()}");`).join("\n");
+ themesStyle.textContent = links;
+}
+
document.addEventListener("DOMContentLoaded", () => {
toggle(Settings.useQuickCss);
addSettingsListener("useQuickCss", toggle);
+
+ initThemes();
+ addSettingsListener("themeLinks", initThemes);
});
diff --git a/src/webpack/common.tsx b/src/webpack/common.tsx
index 773cc149..8c435773 100644
--- a/src/webpack/common.tsx
+++ b/src/webpack/common.tsx
@@ -65,6 +65,7 @@ export let Tooltip: Components.Tooltip;
export let Router: any;
export let TextInput: any;
export let Text: (props: TextProps) => JSX.Element;
+export const TextArea = findByCodeLazy("handleSetRef", "textArea") as React.ComponentType>;
export const Select = LazyComponent(() => findByCode("optionClassName", "popoutPosition", "autoFocus", "maxVisibleItems"));
export const Slider = LazyComponent(() => findByCode("closestMarkerIndex", "stickToMarkers"));