diff --git a/src/userplugins/DiscordColorways/components/CreatorModal.tsx b/src/userplugins/DiscordColorways/components/CreatorModal.tsx
index b63e2655..748df6a8 100644
--- a/src/userplugins/DiscordColorways/components/CreatorModal.tsx
+++ b/src/userplugins/DiscordColorways/components/CreatorModal.tsx
@@ -29,7 +29,7 @@ import { ColorPicker } from "..";
import { knownThemeVars } from "../constants";
import { generateCss, getPreset } from "../css";
import { Colorway } from "../types";
-import { getHex, hexToString, hslToHex, rgbToHex } from "../utils";
+import { colorToHex, getHex, hexToString } from "../utils";
import ConflictingColorsModal from "./ConflictingColorsModal";
import ThemePreviewCategory from "./ThemePreview";
export default function ({
@@ -355,22 +355,7 @@ export default function ({
setSecondaryColor,
setTertiaryColor
];
- hexToString(colorwayID).split(/,#/).forEach((color: string, i: number) => {
- var colorType = "hex";
- if (color.includes("hsl")) {
- colorType = "hsl";
- } else if (color.includes("rgb")) {
- colorType = "rgb";
- }
- color = color.replaceAll(",", "").replace(/.+?\(/, "").replace(")", "").replaceAll(/[ \t]+\/[ \t]+/g, " ").replaceAll("%", "");
- if (colorType === "hsl") {
- color = hslToHex(Number(color.split(" ")[0]), Number(color.split(" ")[1]), Number(color.split(" ")[2]));
- }
- if (colorType === "rgb") {
- color = rgbToHex(Number(color.split(" ")[0]), Number(color.split(" ")[1]), Number(color.split(" ")[2]));
- }
- setColor[i](color.replace("#", ""));
- });
+ hexToString(colorwayID).split(/,#/).forEach((color: string, i: number) => setColor[i](colorToHex(color)));
props.onClose();
}
}}
diff --git a/src/userplugins/DiscordColorways/components/InfoModal.tsx b/src/userplugins/DiscordColorways/components/InfoModal.tsx
index 24d7bdd1..eb5fac1c 100644
--- a/src/userplugins/DiscordColorways/components/InfoModal.tsx
+++ b/src/userplugins/DiscordColorways/components/InfoModal.tsx
@@ -18,6 +18,7 @@ import { Button, Clipboard, Forms, Text, Toasts } from "@webpack/common";
import { ColorwayCSS } from "..";
import { generateCss } from "../css";
import { Colorway } from "../types";
+import { colorToHex } from "../utils";
import ThemePreviewCategory from "./ThemePreview";
export default function ({
@@ -187,12 +188,11 @@ export default function ({
look={Button.Looks.FILLED}
onClick={async () => {
const customColorways = await DataStore.get("customColorways");
- const actveColorwayID = await DataStore.get("actveColorwayID");
const customColorwaysArray: Colorway[] = [];
customColorways.map((color: Colorway, i: number) => {
if (customColorways.length > 0) {
if (color.name === colorwayProps.name) {
- color["dc-import"] = generateCss(color.primary.split("#")[1] || "313338", color.secondary.split("#")[1] || "2b2d31", color.tertiary.split("#")[1] || "1e1f22", color.accent.split("#")[1] || "5865f2", true, true);
+ color["dc-import"] = generateCss(colorToHex(color.primary) || "313338", colorToHex(color.secondary) || "2b2d31", colorToHex(color.tertiary) || "1e1f22", colorToHex(color.accent) || "5865f2", true, true);
customColorwaysArray.push(color);
} else {
customColorwaysArray.push(color);
@@ -200,11 +200,6 @@ export default function ({
if (++i === customColorways.length) {
DataStore.set("customColorways", customColorwaysArray);
}
- if (actveColorwayID === colorwayProps.name) {
- DataStore.set("actveColorway", color["dc-import"]);
- DataStore.set("actveColorwayID", color.name);
- ColorwayCSS.set(color["dc-import"]);
- }
modalProps.onClose();
loadUIProps();
}
@@ -233,23 +228,17 @@ export default function ({
const colorways = data.flatMap(json => json.colorways);
const customColorways = await DataStore.get("customColorways");
- const actveColorwayID = await DataStore.get("actveColorwayID");
const customColorwaysArray: Colorway[] = [];
colorways.map((color: Colorway, i: number) => {
if (colorways.length > 0) {
if (color.name === colorwayProps.name) {
color.name += " (Custom)";
- color["dc-import"] = generateCss(color.primary.split("#")[1] || "313338", color.secondary.split("#")[1] || "2b2d31", color.tertiary.split("#")[1] || "1e1f22", color.accent.split("#")[1] || "5865f2", true, true);
+ color["dc-import"] = generateCss(colorToHex(color.primary) || "313338", colorToHex(color.secondary) || "2b2d31", colorToHex(color.tertiary) || "1e1f22", colorToHex(color.accent) || "5865f2", true, true);
customColorwaysArray.push(color);
}
if (++i === colorways.length) {
DataStore.set("customColorways", [...customColorways, ...customColorwaysArray]);
}
- if (actveColorwayID === colorwayProps.name) {
- DataStore.set("actveColorway", color["dc-import"]);
- DataStore.set("actveColorwayID", color.name);
- ColorwayCSS.set(color["dc-import"]);
- }
modalProps.onClose();
loadUIProps();
}
diff --git a/src/userplugins/DiscordColorways/components/SelectorModal.tsx b/src/userplugins/DiscordColorways/components/SelectorModal.tsx
index e20b0da4..2c1e42d0 100644
--- a/src/userplugins/DiscordColorways/components/SelectorModal.tsx
+++ b/src/userplugins/DiscordColorways/components/SelectorModal.tsx
@@ -8,6 +8,7 @@
import * as DataStore from "@api/DataStore";
import { ModalContent, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal";
+import { findByPropsLazy } from "@webpack";
import {
Button,
Forms,
@@ -27,12 +28,14 @@ import { ColorwayCSS } from "..";
import { defaultColorwaySource, fallbackColorways } from "../constants";
import { generateCss } from "../css";
import { Colorway } from "../types";
-import { getHex } from "../utils";
+import { colorToHex } from "../utils";
import ColorPickerModal from "./ColorPicker";
import CreatorModal from "./CreatorModal";
import { CloseIcon } from "./Icons";
import ColorwayInfoModal from "./InfoModal";
+const { SelectionCircle } = findByPropsLazy("SelectionCircle");
+
export default function ({
modalProps,
}: {
@@ -362,7 +365,7 @@ export default function ({
return (