From 093ec3b30b88ceefc1616ca015b32efb2c128db8 Mon Sep 17 00:00:00 2001 From: thororen <78185467+thororen1234@users.noreply.github.com> Date: Mon, 29 Apr 2024 17:51:57 -0400 Subject: [PATCH] Updates --- src/equicordplugins/betterQuests/index.tsx | 136 ++++++ src/equicordplugins/betterQuests/style.css | 9 + src/equicordplugins/betterQuests/types.ts | 23 + .../components/ColorPicker.tsx | 247 +++------- .../ColorwayCreatorSettingsModal.tsx | 65 +++ .../components/ColorwaysButton.tsx | 66 +-- .../components/CreatorModal.tsx | 135 +++--- .../discordColorways/components/Divider.tsx | 15 - .../discordColorways/components/InfoModal.tsx | 414 ++++++++--------- .../{SelectorModal.tsx => Selector.tsx} | 87 +++- .../components/SettingsTabs/SelectorPage.tsx | 421 ------------------ .../components/SettingsTabs/SettingsPage.tsx | 20 +- .../components/ThemePreview.tsx | 87 ++-- .../discordColorways/constants.ts | 7 + src/equicordplugins/discordColorways/css.ts | 137 +++++- .../discordColorways/index.tsx | 86 ++-- .../discordColorways/style.css | 83 +++- src/equicordplugins/discordColorways/types.ts | 4 +- src/equicordplugins/noAppsAllowed/index.tsx | 32 ++ src/utils/constants.ts | 4 + 20 files changed, 953 insertions(+), 1125 deletions(-) create mode 100644 src/equicordplugins/betterQuests/index.tsx create mode 100644 src/equicordplugins/betterQuests/style.css create mode 100644 src/equicordplugins/betterQuests/types.ts create mode 100644 src/equicordplugins/discordColorways/components/ColorwayCreatorSettingsModal.tsx delete mode 100644 src/equicordplugins/discordColorways/components/Divider.tsx rename src/equicordplugins/discordColorways/components/{SelectorModal.tsx => Selector.tsx} (88%) delete mode 100644 src/equicordplugins/discordColorways/components/SettingsTabs/SelectorPage.tsx create mode 100644 src/equicordplugins/noAppsAllowed/index.tsx diff --git a/src/equicordplugins/betterQuests/index.tsx b/src/equicordplugins/betterQuests/index.tsx new file mode 100644 index 00000000..021a8f38 --- /dev/null +++ b/src/equicordplugins/betterQuests/index.tsx @@ -0,0 +1,136 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import "./style.css"; + +import ErrorBoundary from "@components/ErrorBoundary"; +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; +import { extractAndLoadChunksLazy, findByPropsLazy, findComponentByCodeLazy, findExportedComponentLazy, findStoreLazy } from "@webpack"; +import { useEffect, useState } from "@webpack/common"; + + +const LinkButton = findExportedComponentLazy("LinkButton"); // let {route: e, selected: t, icon: n, iconClassName: a, interactiveClassName: s, text: r, children: o, locationState: d, onClick: f, className: p, role: m, "aria-posinset": C, "aria-setsize": g, ...E} = this.props; +const NumberBadge = findExportedComponentLazy("NumberBadge"); // let { count: l } = this.props +const QuestsComponent = findComponentByCodeLazy(".questsContainer"); // No nessessary props to include + +const questsStore = findStoreLazy("QuestsStore"); + +const requireSettingsMenu = extractAndLoadChunksLazy(['name:"UserSettings"'], /createPromise:.{0,20}Promise\.all\((\[\i\.\i\(".+?"\).+?\])\).then\(\i\.bind\(\i,"(.+?)"\)\).{0,50}"UserSettings"/); +const nav: NavigationSettings = findByPropsLazy("transitionTo", "transitionToGuild", "getHistory"); + + +// Routes used in this plugin (in case someone wants to add new ones) +const routes = new Map(); + +routes.set("/questsMenu", { + path: "/questsMenu", + render: (...props) => , + disableTrack: 1, + redirectTo: "/channels/@me" +}); + + +// Credits to https://www.svgrepo.com/svg/507254/crown +const CrownIcon = () => { + return ( + + + + + ); +}; + + +const QuestPage = (props?: any) => { + const [loadedQuests, setLoaded] = useState(false); + + useEffect(() => { + const loadQuests = async () => { + await requireSettingsMenu(); + setLoaded(true); + }; + + loadQuests(); + }, []); + + return ( +
+ {loadedQuests && } +
+ ); +}; + + +const QuestButtonComponent = () => { + const activeQuests = Array.from(questsStore.quests.values()).filter((q: any) => new Date(q.config.expiresAt).getTime() > Date.now() && q.claimedAt); + return ( + + + {activeQuests.length > 0 && } + + + ); +}; + +const redirectRoute = (ev: BeforeUnloadEvent) => { + const paths = Array.from(routes.keys()); + const path = nav.getHistory().location.pathname; + + if (paths.includes(path)) { + const data = routes.get(path); + ev.preventDefault(); + nav.transitionTo(data?.redirectTo ?? "/channels/@me"); + setTimeout(() => window.location.reload(), 0); + } +}; + +export default definePlugin({ + name: "BetterQuests", + description: "Puts the quest button in more accessibile place.", + authors: [EquicordDevs.kvba], + + start: () => window.addEventListener("beforeunload", redirectRoute), + stop: () => window.removeEventListener("beforeunload", redirectRoute), + + get paths() { + return Array.from(routes.keys()); + }, + + get routes() { + return Array.from(routes.values()); + }, + + patches: [ + { // Add new quest button + find: "\"discord-shop\"", + replacement: { + match: /"discord-shop"\),/, + replace: "$&,$self.QuestButtonComponent()," + } + }, + { // Add new route + find: "Routes.MESSAGE_REQUESTS,render:", + replacement: { + match: /\((0,.{0,10}\.jsx\)\(.{0,10}\.default,){path:.{0,10}\.Routes\.MESSAGE_REQUESTS,.{0,100}?\),/, + replace: "$&...$self.routes.map(r => (($1r)))," + } + }, + { + find: 'on("LAUNCH_APPLICATION"', + replacement: { + match: /path:\[.{0,500}Routes\.MESSAGE_REQUESTS,/, + replace: "$&...$self.paths," + } + } + ], + + QuestButtonComponent +}); diff --git a/src/equicordplugins/betterQuests/style.css b/src/equicordplugins/betterQuests/style.css new file mode 100644 index 00000000..55f90f6d --- /dev/null +++ b/src/equicordplugins/betterQuests/style.css @@ -0,0 +1,9 @@ +.quests-container { + width: 100%; + overflow: hidden; + display: flex; + flex-direction: column; + background: var(--bg-overlay-chat,var(--background-primary)); + padding-left: 50px; + padding-right: 50px; +} diff --git a/src/equicordplugins/betterQuests/types.ts b/src/equicordplugins/betterQuests/types.ts new file mode 100644 index 00000000..da64bade --- /dev/null +++ b/src/equicordplugins/betterQuests/types.ts @@ -0,0 +1,23 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +type RouteData = { + path: string, + render: (props?: any) => JSX.Element, + disableTrack: 1 | 0; + redirectTo?: string; +}; + +type NavigationSettings = { + /** Transition to a route */ + transitionTo: (path: string) => unknown, + getHistory: () => { + location: { + /** The current route */ + pathname: string; + }; + }, +}; diff --git a/src/equicordplugins/discordColorways/components/ColorPicker.tsx b/src/equicordplugins/discordColorways/components/ColorPicker.tsx index 195eecb9..d4ae6adc 100644 --- a/src/equicordplugins/discordColorways/components/ColorPicker.tsx +++ b/src/equicordplugins/discordColorways/components/ColorPicker.tsx @@ -19,202 +19,73 @@ import { useState, } from "@webpack/common"; +import { mainColors } from "../constants"; import { colorVariables } from "../css"; - -interface ToolboxItem { - title: string; - onClick: () => void; - id?: string; - iconClassName?: string; -} - -const ColorVarItems: ToolboxItem[] = colorVariables.map((colorVariable: string) => { - return { - title: "Copy " + colorVariable, - onClick: () => { - function getHex(str: string): string { return Object.assign(document.createElement("canvas").getContext("2d") as {}, { fillStyle: str }).fillStyle; } - Clipboard.copy(getHex(getComputedStyle(document.body).getPropertyValue("--" + colorVariable))); - Toasts.show({ message: "Color " + colorVariable + " copied to clipboard", id: "toolbox-color-var-copied", type: 1 }); - }, - id: colorVariable - }; -}); - -const ToolboxItems: ToolboxItem[] = [ - { - title: "Copy Accent Color", - onClick: () => { - function getHex(str: string): string { - return Object.assign( - document.createElement("canvas").getContext("2d") as {}, - { fillStyle: str } - ).fillStyle; - } - Clipboard.copy( - getHex( - getComputedStyle(document.body).getPropertyValue( - "--brand-experiment" - ) - ) - ); - Toasts.show({ - message: "Accent color copied to clipboard", - id: "toolbox-accent-color-copied", - type: 1, - }); - }, - id: "colorways-toolbox_copy-accent", - iconClassName: "copy", - }, - { - title: "Copy Primary Color", - onClick: () => { - function getHex(str: string): string { - return Object.assign( - document.createElement("canvas").getContext("2d") as {}, - { fillStyle: str } - ).fillStyle; - } - Clipboard.copy( - getHex( - getComputedStyle(document.body).getPropertyValue( - "--background-primary" - ) - ) - ); - Toasts.show({ - message: "Primary color copied to clipboard", - id: "toolbox-primary-color-copied", - type: 1, - }); - }, - id: "colorways-toolbox_copy-primary", - iconClassName: "copy", - }, - { - title: "Copy Secondary Color", - onClick: () => { - function getHex(str: string): string { - return Object.assign( - document.createElement("canvas").getContext("2d") as {}, - { fillStyle: str } - ).fillStyle; - } - Clipboard.copy( - getHex( - getComputedStyle(document.body).getPropertyValue( - "--background-secondary" - ) - ) - ); - Toasts.show({ - message: "Secondary color copied to clipboard", - id: "toolbox-secondary-color-copied", - type: 1, - }); - }, - id: "colorways-toolbox_copy-secondary", - iconClassName: "copy", - }, - { - title: "Copy Tertiary Color", - onClick: () => { - function getHex(str: string): string { - return Object.assign( - document.createElement("canvas").getContext("2d") as {}, - { fillStyle: str } - ).fillStyle; - } - Clipboard.copy( - getHex( - getComputedStyle(document.body).getPropertyValue( - "--background-tertiary" - ) - ) - ); - Toasts.show({ - message: "Tertiary color copied to clipboard", - id: "toolbox-tertiary-color-copied", - type: 1, - }); - }, - id: "colorways-toolbox_copy-tertiary", - iconClassName: "copy", - } -]; +import { getHex } from "../utils"; export default function ({ modalProps }: { modalProps: ModalProps; }) { - const [colorVarItems, setColorVarItems] = useState(ColorVarItems); + const [ColorVars, setColorVars] = useState(colorVariables); const [collapsedSettings, setCollapsedSettings] = useState(true); - let results: ToolboxItem[]; + let results: string[]; function searchToolboxItems(e: string) { results = []; - ColorVarItems.find((ToolboxItem: ToolboxItem) => { - if (ToolboxItem.title.toLowerCase().includes(e.toLowerCase())) { - results.push(ToolboxItem); + colorVariables.find((colorVariable: string) => { + if (colorVariable.toLowerCase().includes(e.toLowerCase())) { + results.push(colorVariable); } }); - setColorVarItems(results); + setColorVars(results); } - return ( - - - { - searchToolboxItems(e); - if (e) { - setCollapsedSettings(false); - } else { - setCollapsedSettings(true); - } - }} - /> - - - - {colorVarItems.map((toolboxItem: ToolboxItem) => { - return ( -
- {toolboxItem.title} -
- ); - })} -
- - {ToolboxItems.map((toolboxItem: ToolboxItem, i: number) =>
- - {toolboxItem.title} -
- )} -
-
- ); + return + + { + searchToolboxItems(e); + if (e) { + setCollapsedSettings(false); + } else { + setCollapsedSettings(true); + } + }} + /> + + + + {ColorVars.map((colorVariable: string) =>
{ + Clipboard.copy(getHex(getComputedStyle(document.body).getPropertyValue("--" + colorVariable))); + Toasts.show({ message: "Color " + colorVariable + " copied to clipboard", id: "toolbox-color-var-copied", type: 1 }); + }} style={{ "--brand-experiment": `var(--${colorVariable})` } as React.CSSProperties}> + {`Copy ${colorVariable}`} +
)} +
+ + {mainColors.map(mainColor =>
+ { + Clipboard.copy(getHex(getComputedStyle(document.body).getPropertyValue(mainColor.var))); + Toasts.show({ message: `${mainColor.title} color copied to clipboard`, id: `toolbox-${mainColor.name}-color-copied`, type: 1 }); + }} width={20} height={20} className="colorwayToolbox-listItemSVG" /> + {`Copy ${mainColor.title} Color`} +
+ )} +
+
; } diff --git a/src/equicordplugins/discordColorways/components/ColorwayCreatorSettingsModal.tsx b/src/equicordplugins/discordColorways/components/ColorwayCreatorSettingsModal.tsx new file mode 100644 index 00000000..b1b2f4c2 --- /dev/null +++ b/src/equicordplugins/discordColorways/components/ColorwayCreatorSettingsModal.tsx @@ -0,0 +1,65 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2024 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { ModalContent, ModalFooter, ModalHeader, ModalProps, ModalRoot } from "@utils/modal"; +import { Button, Forms, ScrollerThin, Switch, Text, useState } from "@webpack/common"; + +import { getPreset } from "../css"; + +export default function ({ modalProps, onSettings, presetId, hasTintedText, hasDiscordSaturation }: { modalProps: ModalProps, presetId: string, hasTintedText: boolean, hasDiscordSaturation: boolean, onSettings: ({ presetId, tintedText, discordSaturation }: { presetId: string, tintedText: boolean, discordSaturation: boolean; }) => void; }) { + const [tintedText, setTintedText] = useState(hasTintedText); + const [discordSaturation, setDiscordSaturation] = useState(hasDiscordSaturation); + const [preset, setPreset] = useState(presetId); + return + Creator Settings + +
+ + Presets: + + + {Object.values(getPreset()).map(pre => { + return
{ + setPreset(pre.id); + }}> + + {pre.name} +
; + })} +
+
+ Use colored text + Use Discord's saturation +
+ + + + +
; +} diff --git a/src/equicordplugins/discordColorways/components/ColorwaysButton.tsx b/src/equicordplugins/discordColorways/components/ColorwaysButton.tsx index e003ccc1..f63b0039 100644 --- a/src/equicordplugins/discordColorways/components/ColorwaysButton.tsx +++ b/src/equicordplugins/discordColorways/components/ColorwaysButton.tsx @@ -10,7 +10,7 @@ import { FluxDispatcher, Text, Tooltip, useEffect, useState } from "@webpack/com import { FluxEvents } from "@webpack/types"; import { PalleteIcon } from "./Icons"; -import SelectorModal from "./SelectorModal"; +import Selector from "./Selector"; export default function ({ listItemClass = "ColorwaySelectorBtnContainer", @@ -46,49 +46,23 @@ export default function ({ setVisibility(isVisible); }); - if (!isThin) { - return (Colorways, - {"Active Colorway: " + activeColorway} - ]} position="right" tooltipContentClassName={listItemTooltipClass} - > - {({ onMouseEnter, onMouseLeave, onClick }) => visibility ?
-
{ - onMouseEnter(); - setActiveColorway(await DataStore.get("actveColorwayID") || "None"); - }} - onMouseLeave={onMouseLeave} - onClick={() => { - onClick(); - openModal(props => ); - }} - >
-
: <>} -
- ); - } else { - return (Colorways, - {"Active Colorway: " + activeColorway} - ]} position="right" tooltipContentClassName={listItemTooltipClass} - > - {({ onMouseEnter, onMouseLeave, onClick }) => visibility ?
-
{ - onMouseEnter(); - setActiveColorway(await DataStore.get("actveColorwayID") || "None"); - }} - onMouseLeave={onMouseLeave} - onClick={() => { - onClick(); - openModal(props => ); - }} - >Colorways
-
: <>} -
- ); - } + return Colorways{"Active Colorway: " + activeColorway} : {"Active Colorway: " + activeColorway} + } position="right" tooltipContentClassName="colorwaysBtn-tooltipContent" + > + {({ onMouseEnter, onMouseLeave, onClick }) => visibility ?
+
{ + onMouseEnter(); + setActiveColorway(await DataStore.get("actveColorwayID") || "None"); + }} + onMouseLeave={onMouseLeave} + onClick={() => { + onClick(); + openModal((props: any) => ); + }} + >{isThin ? Colorways : }
+
: <>} +
; } diff --git a/src/equicordplugins/discordColorways/components/CreatorModal.tsx b/src/equicordplugins/discordColorways/components/CreatorModal.tsx index cd4fcdf9..aec1bebf 100644 --- a/src/equicordplugins/discordColorways/components/CreatorModal.tsx +++ b/src/equicordplugins/discordColorways/components/CreatorModal.tsx @@ -16,8 +16,6 @@ import { import { Button, Forms, - ScrollerThin, - Switch, Text, TextInput, useEffect, @@ -27,9 +25,10 @@ import { import { ColorPicker } from ".."; import { knownThemeVars } from "../constants"; -import { generateCss, getPreset } from "../css"; +import { generateCss, getPreset, gradientPresetIds, pureGradientBase } from "../css"; import { Colorway } from "../types"; import { colorToHex, getHex, hexToString } from "../utils"; +import ColorwayCreatorSettingsModal from "./ColorwayCreatorSettingsModal"; import ConflictingColorsModal from "./ConflictingColorsModal"; import InputColorwayIdModal from "./InputColorwayIdModal"; import ThemePreviewCategory from "./ThemePreview"; @@ -52,7 +51,7 @@ export default function ({ const [collapsedSettings, setCollapsedSettings] = useState(true); const [collapsedPresets, setCollapsedPresets] = useState(true); const [preset, setPreset] = useState("default"); - const [presetColorArray, setPresetColorArray] = useState(["accent", "primary", "secondary", "tertiary"]); + const [presetColorArray, setPresetColorArray] = useState(["primary", "secondary", "tertiary", "accent"]); const colorProps = { accent: { @@ -80,21 +79,18 @@ export default function ({ useEffect(() => { const parsedID = colorwayID?.split("colorway:")[1]; if (parsedID) { - const allEqual = (arr: any[]) => arr.every(v => v === arr[0]); if (!parsedID) { throw new Error("Please enter a Colorway ID"); - } else if (parsedID.length < 62) { - throw new Error("Invalid Colorway ID"); } else if (!hexToString(parsedID).includes(",")) { throw new Error("Invalid Colorway ID"); - } else if (!allEqual(hexToString(parsedID).split(",").map((e: string) => e.match("#")!.length)) && hexToString(parsedID).split(",").map((e: string) => e.match("#")!.length)[0] !== 1) { - throw new Error("Invalid Colorway ID"); } else { - const colorArray: string[] = hexToString(parsedID).split(","); - setAccentColor(colorArray[0].split("#")[1]); - setPrimaryColor(colorArray[1].split("#")[1]); - setSecondaryColor(colorArray[2].split("#")[1]); - setTertiaryColor(colorArray[3].split("#")[1]); + const setColor = [ + setAccentColor, + setPrimaryColor, + setSecondaryColor, + setTertiaryColor + ]; + hexToString(parsedID).split(/,#/).forEach((color: string, i: number) => setColor[i](colorToHex(color))); } } }); @@ -125,7 +121,7 @@ export default function ({ onChange={setColorwayName} />
- + Colors:
@@ -145,61 +141,37 @@ export default function ({ })}
-
-
setCollapsedSettings(!collapsedSettings)}> - Settings - -
- -
setTintedText(!tintedText)}> - Use colored text - -
-
setDiscordSaturation(!discordSaturation)}> - Use Discord's saturation - -
-
+
openModal((props: ModalProps) => { + setPreset(presetId); + setPresetColorArray(getPreset()[presetId].colors); + setDiscordSaturation(discordSaturation); + setTintedText(tintedText); + }} />)}> + Settings & Presets +
-
-
setCollapsedPresets(!collapsedPresets)}> - Presets - -
- -
{ - setPreset("default"); - setPresetColorArray(["primary", "secondary", "tertiary", "accent"]); - }}> - - Default -
- {Object.values(getPreset()).map(pre => { - return
{ - setPreset(pre.id); - setPresetColorArray(pre.colors); - }}> - - {pre.name} -
; - })} -
-
- + -
-
- - CSS: - - { + const colorwayIDArray = `${colorwayProps.accent},${colorwayProps.primary},${colorwayProps.secondary},${colorwayProps.tertiary}`; + const colorwayID = stringToHex(colorwayIDArray); + Clipboard.copy(colorwayID); + Toasts.show({ + message: "Copied Colorway ID Successfully", + type: 1, + id: "copy-colorway-id-notify", + }); + }} > - {colorwayProps["dc-import"]} - -
- + Copy Colorway ID + + {discrimProps && } + - - - {discrimProps && } - + + {discrimProps ? : - - {discrimProps ? : } - - - - ); + const customColorways = await DataStore.get("customColorways"); + 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(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]); + } + modalProps.onClose(); + loadUIProps(); + } + }); + }} + > + Update + } + + + {colorwayProps["dc-import"]} + + + + +
+ + ; } diff --git a/src/equicordplugins/discordColorways/components/SelectorModal.tsx b/src/equicordplugins/discordColorways/components/Selector.tsx similarity index 88% rename from src/equicordplugins/discordColorways/components/SelectorModal.tsx rename to src/equicordplugins/discordColorways/components/Selector.tsx index 1ede727b..66df1138 100644 --- a/src/equicordplugins/discordColorways/components/SelectorModal.tsx +++ b/src/equicordplugins/discordColorways/components/Selector.tsx @@ -7,6 +7,8 @@ /* eslint-disable arrow-parens */ import * as DataStore from "@api/DataStore"; +import { Flex } from "@components/Flex"; +import { SettingsTab } from "@components/VencordSettings/shared"; import { ModalContent, ModalHeader, ModalProps, ModalRoot, openModal } from "@utils/modal"; import { findByPropsLazy } from "@webpack"; import { @@ -23,10 +25,11 @@ import { useEffect, useState, } from "@webpack/common"; +import { ReactNode } from "react"; import { ColorwayCSS } from ".."; import { defaultColorwaySource, fallbackColorways } from "../constants"; -import { generateCss } from "../css"; +import { generateCss, gradientBase } from "../css"; import { Colorway } from "../types"; import { colorToHex } from "../utils"; import ColorPickerModal from "./ColorPicker"; @@ -36,10 +39,46 @@ import ColorwayInfoModal from "./InfoModal"; const { SelectionCircle } = findByPropsLazy("SelectionCircle"); +function SelectorContainer({ children, isSettings, modalProps }: { children: ReactNode, isSettings?: boolean, modalProps: ModalProps; }) { + if (!isSettings) { + return + {children} + ; + } else { + return +
+ {children} +
+
; + } +} + +function SelectorHeader({ children, isSettings }: { children: ReactNode, isSettings?: boolean; }) { + if (!isSettings) { + return + {children} + ; + } else { + return + {children} + ; + } +} + +function SelectorContent({ children, isSettings }: { children: ReactNode, isSettings?: boolean; }) { + if (!isSettings) { + return {children}; + } else { + return <>{children}; + } +} + export default function ({ modalProps, + isSettings }: { - modalProps: ModalProps; + modalProps: ModalProps, + isSettings?: boolean; }): JSX.Element | any { const [currentColorway, setCurrentColorway] = useState(""); const [colorways, setColorways] = useState([]); @@ -179,8 +218,8 @@ export default function ({ } return ( - - + + { - setVisibility(value); - }} isSelected={value => visibility === value} serialize={String} /> - [searchColorways, setSearchString].forEach(t => t(e))} - /> - - {({ onMouseEnter, onMouseLeave }) => { - return setShowReloadMenu(false)} - renderPopout={() => ReloadPopout(() => setShowReloadMenu(false))} - > - {(_, { isShown }) => ( - - )} - ; - }} - - - {({ onMouseEnter, onMouseLeave }) => } - - - {({ onMouseEnter, onMouseLeave }) => } - - -
-
- {visibleColorwayArray.length === 0 && - - No colorways... - - } - {visibleColorwayArray.map((color, ind) => { - var colors: Array = color.colors || [ - "accent", - "primary", - "secondary", - "tertiary", - ]; - return ( - - {({ onMouseEnter, onMouseLeave }) => { - return ( -
{ - const [ - onDemandWays, - onDemandWaysTintedText, - onDemandWaysDiscordSaturation - ] = await DataStore.getMany([ - "onDemandWays", - "onDemandWaysTintedText", - "onDemandWaysDiscordSaturation" - ]); - if (currentColorway === color.name) { - DataStore.set("actveColorwayID", null); - DataStore.set("actveColorway", null); - ColorwayCSS.remove(); - } else { - DataStore.set("activeColorwayColors", color.colors); - DataStore.set("actveColorwayID", color.name); - if (onDemandWays) { - const demandedColorway = generateCss( - colorToHex(color.primary), - colorToHex(color.secondary), - colorToHex(color.tertiary), - colorToHex(color.accent), - onDemandWaysTintedText, - onDemandWaysDiscordSaturation - ); - DataStore.set("actveColorway", demandedColorway); - ColorwayCSS.set(demandedColorway); - } else { - DataStore.set("actveColorway", color["dc-import"]); - ColorwayCSS.set(color["dc-import"]); - } - } - setCurrentColorway(await DataStore.get("actveColorwayID") as string); - }} - > -
{ - e.stopPropagation(); - openModal((props) => ( - - )); - }} - > - - - -
-
- {colors.map((colorItm) =>
- )} -
- {currentColorway === color.name && } -
- ); - }} - - ); - })} -
-
- - ); -} diff --git a/src/equicordplugins/discordColorways/components/SettingsTabs/SettingsPage.tsx b/src/equicordplugins/discordColorways/components/SettingsTabs/SettingsPage.tsx index 90a42377..774a4d27 100644 --- a/src/equicordplugins/discordColorways/components/SettingsTabs/SettingsPage.tsx +++ b/src/equicordplugins/discordColorways/components/SettingsTabs/SettingsPage.tsx @@ -9,7 +9,7 @@ import { Flex } from "@components/Flex"; import { CopyIcon } from "@components/Icons"; import { Link } from "@components/Link"; import { SettingsTab } from "@components/VencordSettings/shared"; -import { ModalContent, ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal"; +import { ModalFooter, ModalHeader, ModalRoot, openModal } from "@utils/modal"; import { Button, Clipboard, @@ -24,10 +24,9 @@ import { } from "@webpack/common"; import { FluxEvents } from "@webpack/types"; -import { versionData } from "../.."; +import { versionData } from "../../../discordColorways"; import { defaultColorwaySource, fallbackColorways, knownColorwaySources } from "../../constants"; import { Colorway } from "../../types"; -import Divider from "../Divider"; import { CloseIcon } from "../Icons"; export default function () { @@ -88,18 +87,17 @@ export default function () { onClick={() => { openModal(props => { var colorwaySource = ""; - return + return Add a source: - - colorwaySource = e} - /> - + colorwaySource = e} + style={{ margin: "8px", width: "calc(100% - 16px)" }} + /> ; - return null; - }); + addAccessory("colorways-btn", props => String(props.message.content).match(/colorway:[0-9a-f]{0,100}/) ? : null); }, stop() { removeServerListElement(ServerListRenderPosition.In, this.ColorwaysButton); - disableStyle(style); ColorwayCSS.remove(); removeAccessory("colorways-btn"); diff --git a/src/equicordplugins/discordColorways/style.css b/src/equicordplugins/discordColorways/style.css index 33c3f9d8..600a2bd2 100644 --- a/src/equicordplugins/discordColorways/style.css +++ b/src/equicordplugins/discordColorways/style.css @@ -158,7 +158,6 @@ justify-content: space-between; gap: 8px; position: relative; - border-radius: 4px; box-sizing: border-box; } @@ -302,7 +301,6 @@ display: flex; flex-direction: column; padding: 10px; - gap: 5px; border-radius: 4px; background-color: var(--background-secondary); box-sizing: border-box; @@ -347,7 +345,7 @@ max-height: 185px; } -.colorwaysCreator-settingCat-collapsed>.colorwaysCreator-settingsList, +.colorwaysCreator-settingCat-collapsed>:is(.colorwaysCreator-settingsList, .colorwayInfo-cssCodeblock), .colorwaysColorpicker-collapsed { display: none !important; } @@ -383,8 +381,8 @@ .colorwaysPreview-modal { max-width: unset !important; max-height: unset !important; - width: 90vw; - height: 90vh; + width: fit-content; + height: fit-content; } .colorwaysPreview-titlebar { @@ -454,7 +452,7 @@ margin-bottom: 4px; } -.colorwaysPreview-collapsed .colorwaysPreview-container { +.colorwaysPreview-collapsed .colorwaysPreview-wrapper { display: none; } @@ -556,26 +554,26 @@ margin: 8px; margin-bottom: 12px; margin-top: 0; - flex: 1 0 auto; + flex: 1 1 auto; } .colorwayPreview-filler { width: 100%; height: 100%; + flex: 0 1 auto; } .colorwayPreview-topShadow { box-shadow: 0 1px 0 hsl(var(--primary-900-hsl)/20%), 0 1.5px 0 hsl(var(--primary-860-hsl)/5%), 0 2px 0 hsl(var(--primary-900-hsl)/5%); width: 100%; height: 32px; - flex: 1 0 auto; - transition: background-color .1s linear; font-family: var(--font-display); font-weight: 500; padding: 12px 16px; box-sizing: border-box; align-items: center; display: flex; + flex: 1 0 auto; } .colorwayPreview-channels>.colorwayPreview-topShadow { @@ -1144,3 +1142,70 @@ border-color: var(--info-warning-foreground); color: var(--info-warning-text); } + +/* stylelint-disable-next-line no-duplicate-selectors */ +.colorwaysPreview-modal { + width: 90vw !important; + height: 90vh !important; + max-height: unset !important; +} + +.colorwaysPresetPicker-content { + padding: 16px; +} + +.colorwaysPresetPicker { + width: 600px; +} + +.colorwaysCreator-setting { + display: flex; + flex-direction: row; + justify-content: space-between; + border-radius: 4px; + background-color: var(--background-secondary); + box-sizing: border-box; + color: var(--header-secondary); + padding: 10px 18px; + padding-right: 10px; + cursor: pointer; + align-items: center; +} + +.colorwaysCreator-setting:hover { + background-color: var(--background-modifier-hover); +} + +:root { + --dc-picker-svg: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' class='vc-pallete-icon vc-icon' role='img' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath fill='currentColor' d='M 12 7.5 C 13.242188 7.5 14.25 6.492188 14.25 5.25 C 14.25 4.007812 13.242188 3 12 3 C 10.757812 3 9.75 4.007812 9.75 5.25 C 9.75 6.492188 10.757812 7.5 12 7.5 Z M 18 12 C 19.242188 12 20.25 10.992188 20.25 9.75 C 20.25 8.507812 19.242188 7.5 18 7.5 C 16.757812 7.5 15.75 8.507812 15.75 9.75 C 15.75 10.992188 16.757812 12 18 12 Z M 8.25 10.5 C 8.25 11.742188 7.242188 12.75 6 12.75 C 4.757812 12.75 3.75 11.742188 3.75 10.5 C 3.75 9.257812 4.757812 8.25 6 8.25 C 7.242188 8.25 8.25 9.257812 8.25 10.5 Z M 9 19.5 C 10.242188 19.5 11.25 18.492188 11.25 17.25 C 11.25 16.007812 10.242188 15 9 15 C 7.757812 15 6.75 16.007812 6.75 17.25 C 6.75 18.492188 7.757812 19.5 9 19.5 Z M 9 19.5 M 24 12 C 24 16.726562 21.199219 15.878906 18.648438 15.105469 C 17.128906 14.644531 15.699219 14.210938 15 15 C 14.09375 16.023438 14.289062 17.726562 14.472656 19.378906 C 14.738281 21.742188 14.992188 24 12 24 C 5.371094 24 0 18.628906 0 12 C 0 5.371094 5.371094 0 12 0 C 18.628906 0 24 5.371094 24 12 Z M 12 22.5 C 12.917969 22.5 12.980469 22.242188 12.984375 22.234375 C 13.097656 22.015625 13.167969 21.539062 13.085938 20.558594 C 13.066406 20.304688 13.03125 20.003906 12.996094 19.671875 C 12.917969 18.976562 12.828125 18.164062 12.820312 17.476562 C 12.804688 16.417969 12.945312 15.0625 13.875 14.007812 C 14.429688 13.382812 15.140625 13.140625 15.78125 13.078125 C 16.390625 13.023438 17 13.117188 17.523438 13.234375 C 18.039062 13.351562 18.574219 13.515625 19.058594 13.660156 L 19.101562 13.675781 C 19.621094 13.832031 20.089844 13.972656 20.53125 14.074219 C 21.511719 14.296875 21.886719 14.199219 22.019531 14.109375 C 22.074219 14.070312 22.5 13.742188 22.5 12 C 22.5 6.199219 17.800781 1.5 12 1.5 C 6.199219 1.5 1.5 6.199219 1.5 12 C 1.5 17.800781 6.199219 22.5 12 22.5 Z M 12 22.5'%3E%3C/path%3E%3C/svg%3E"); + --dc-settings-svg : url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' viewBox='0 0 24 24' width='24' height='24' preserveAspectRatio='xMidYMid meet' style='width: 100%25; height: 100%25; transform: translate3d(0px, 0px, 0px); content-visibility: visible;'%3E%3Cdefs%3E%3CclipPath id='__lottie_element_97'%3E%3Crect width='24' height='24' x='0' y='0'%3E%3C/rect%3E%3C/clipPath%3E%3CclipPath id='__lottie_element_99'%3E%3Cpath d='M0,0 L600,0 L600,600 L0,600z'%3E%3C/path%3E%3C/clipPath%3E%3C/defs%3E%3Cg clip-path='url(%23__lottie_element_97)'%3E%3Cg clip-path='url(%23__lottie_element_99)' transform='matrix(0.03999999910593033,0,0,0.03999999910593033,0,0)' opacity='1' style='display: block;'%3E%3Cg transform='matrix(25,0,0,25,300,300)' opacity='1' style='display: block;'%3E%3Cg opacity='1' transform='matrix(1,0,0,1,0,0)'%3E%3Cpath fill='rgb(88,101,242)' fill-opacity='1' d=' M-1.4420000314712524,-10.906000137329102 C-1.8949999809265137,-10.847000122070312 -2.1470000743865967,-10.375 -2.078000068664551,-9.92300033569336 C-1.899999976158142,-8.756999969482422 -2.265000104904175,-7.7210001945495605 -3.061000108718872,-7.390999794006348 C-3.8570001125335693,-7.060999870300293 -4.8480000495910645,-7.534999847412109 -5.546000003814697,-8.484999656677246 C-5.816999912261963,-8.852999687194824 -6.329999923706055,-9.008999824523926 -6.691999912261963,-8.730999946594238 C-7.458000183105469,-8.142999649047852 -8.142999649047852,-7.458000183105469 -8.730999946594238,-6.691999912261963 C-9.008999824523926,-6.329999923706055 -8.852999687194824,-5.816999912261963 -8.484999656677246,-5.546000003814697 C-7.534999847412109,-4.8480000495910645 -7.060999870300293,-3.8570001125335693 -7.390999794006348,-3.061000108718872 C-7.7210001945495605,-2.265000104904175 -8.756999969482422,-1.899999976158142 -9.92300033569336,-2.078000068664551 C-10.375,-2.1470000743865967 -10.847000122070312,-1.8949999809265137 -10.906000137329102,-1.4420000314712524 C-10.968000411987305,-0.9700000286102295 -11,-0.48899999260902405 -11,0 C-11,0.48899999260902405 -10.968000411987305,0.9700000286102295 -10.906000137329102,1.4420000314712524 C-10.847000122070312,1.8949999809265137 -10.375,2.1470000743865967 -9.92300033569336,2.078000068664551 C-8.756999969482422,1.899999976158142 -7.7210001945495605,2.265000104904175 -7.390999794006348,3.061000108718872 C-7.060999870300293,3.8570001125335693 -7.534999847412109,4.8470001220703125 -8.484999656677246,5.546000003814697 C-8.852999687194824,5.816999912261963 -9.008999824523926,6.328999996185303 -8.730999946594238,6.691999912261963 C-8.142999649047852,7.458000183105469 -7.458000183105469,8.142999649047852 -6.691999912261963,8.730999946594238 C-6.329999923706055,9.008999824523926 -5.816999912261963,8.852999687194824 -5.546000003814697,8.484999656677246 C-4.8480000495910645,7.534999847412109 -3.8570001125335693,7.060999870300293 -3.061000108718872,7.390999794006348 C-2.265000104904175,7.7210001945495605 -1.899999976158142,8.756999969482422 -2.078000068664551,9.92300033569336 C-2.1470000743865967,10.375 -1.8949999809265137,10.847000122070312 -1.4420000314712524,10.906000137329102 C-0.9700000286102295,10.968000411987305 -0.48899999260902405,11 0,11 C0.48899999260902405,11 0.9700000286102295,10.968000411987305 1.4420000314712524,10.906000137329102 C1.8949999809265137,10.847000122070312 2.1470000743865967,10.375 2.078000068664551,9.92300033569336 C1.899999976158142,8.756999969482422 2.2660000324249268,7.7210001945495605 3.062000036239624,7.390999794006348 C3.8580000400543213,7.060999870300293 4.8480000495910645,7.534999847412109 5.546000003814697,8.484999656677246 C5.816999912261963,8.852999687194824 6.328999996185303,9.008999824523926 6.691999912261963,8.730999946594238 C7.458000183105469,8.142999649047852 8.142999649047852,7.458000183105469 8.730999946594238,6.691999912261963 C9.008999824523926,6.328999996185303 8.852999687194824,5.816999912261963 8.484999656677246,5.546000003814697 C7.534999847412109,4.8480000495910645 7.060999870300293,3.8570001125335693 7.390999794006348,3.061000108718872 C7.7210001945495605,2.265000104904175 8.756999969482422,1.899999976158142 9.92300033569336,2.078000068664551 C10.375,2.1470000743865967 10.847000122070312,1.8949999809265137 10.906000137329102,1.4420000314712524 C10.968000411987305,0.9700000286102295 11,0.48899999260902405 11,0 C11,-0.48899999260902405 10.968000411987305,-0.9700000286102295 10.906000137329102,-1.4420000314712524 C10.847000122070312,-1.8949999809265137 10.375,-2.1470000743865967 9.92300033569336,-2.078000068664551 C8.756999969482422,-1.899999976158142 7.7210001945495605,-2.265000104904175 7.390999794006348,-3.061000108718872 C7.060999870300293,-3.8570001125335693 7.534999847412109,-4.8480000495910645 8.484999656677246,-5.546000003814697 C8.852999687194824,-5.816999912261963 9.008999824523926,-6.329999923706055 8.730999946594238,-6.691999912261963 C8.142999649047852,-7.458000183105469 7.458000183105469,-8.142999649047852 6.691999912261963,-8.730999946594238 C6.328999996185303,-9.008999824523926 5.817999839782715,-8.852999687194824 5.546999931335449,-8.484999656677246 C4.848999977111816,-7.534999847412109 3.8580000400543213,-7.060999870300293 3.062000036239624,-7.390999794006348 C2.2660000324249268,-7.7210001945495605 1.9010000228881836,-8.756999969482422 2.0789999961853027,-9.92300033569336 C2.1480000019073486,-10.375 1.8949999809265137,-10.847000122070312 1.4420000314712524,-10.906000137329102 C0.9700000286102295,-10.968000411987305 0.48899999260902405,-11 0,-11 C-0.48899999260902405,-11 -0.9700000286102295,-10.968000411987305 -1.4420000314712524,-10.906000137329102z M4,0 C4,2.2090001106262207 2.2090001106262207,4 0,4 C-2.2090001106262207,4 -4,2.2090001106262207 -4,0 C-4,-2.2090001106262207 -2.2090001106262207,-4 0,-4 C2.2090001106262207,-4 4,-2.2090001106262207 4,0z'%3E%3C/path%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/g%3E%3C/svg%3E"); + --dc-ondemand-svg: url("https://icons.getbootstrap.com/assets/icons/check-circle.svg"); +} + +.dc-colorway-selector::before { + /* stylelint-disable-next-line property-no-vendor-prefix */ + -webkit-mask: var(--dc-picker-svg) center/contain no-repeat !important; + mask: var(--dc-picker-svg) center/contain no-repeat !important +} + +.dc-colorway-settings::before { + /* stylelint-disable-next-line property-no-vendor-prefix */ + -webkit-mask: var(--dc-settings-svg) center/contain no-repeat !important; + mask: var(--dc-settings-svg) center/contain no-repeat !important +} + +.dc-colorway-ondemand::before { + /* stylelint-disable-next-line property-no-vendor-prefix */ + -webkit-mask: var(--dc-ondemand-svg) center/contain no-repeat !important; + mask: var(--dc-ondemand-svg) center/contain no-repeat !important +} + +.dc-colorway-management::before { + /* stylelint-disable-next-line property-no-vendor-prefix */ + -webkit-mask: var(--dc-settings-svg) center/contain no-repeat !important; + mask: var(--dc-settings-svg) center/contain no-repeat !important +} + +.colorwaySourceModal { + min-height: unset; +} diff --git a/src/equicordplugins/discordColorways/types.ts b/src/equicordplugins/discordColorways/types.ts index 15fa776d..cbf08fa8 100644 --- a/src/equicordplugins/discordColorways/types.ts +++ b/src/equicordplugins/discordColorways/types.ts @@ -5,6 +5,7 @@ */ export interface Colorway { + [key: string]: any, name: string, "dc-import": string, accent: string, @@ -17,7 +18,8 @@ export interface Colorway { colors?: string[], isGradient?: boolean, sourceUrl?: string, - sourceName?: string; + sourceName?: string, + linearGradient?: string; } export interface ColorPickerProps { diff --git a/src/equicordplugins/noAppsAllowed/index.tsx b/src/equicordplugins/noAppsAllowed/index.tsx new file mode 100644 index 00000000..ef4437e4 --- /dev/null +++ b/src/equicordplugins/noAppsAllowed/index.tsx @@ -0,0 +1,32 @@ +/* + * Vencord, a Discord client mod + * Copyright (c) 2023 Vendicated and contributors + * SPDX-License-Identifier: GPL-3.0-or-later + */ + +import { EquicordDevs } from "@utils/constants"; +import definePlugin from "@utils/types"; + +export default definePlugin({ + name: "noAppsAllowed", + description: "returns the bot's tag :skulk:", + authors: [EquicordDevs.kvba], + + patches: [ + { + find: "\"APP_TAG\"", + replacement: { + match: /"APP_TAG":".*?"/, + replace: "\"APP_TAG\":\"BOT\"" + } + }, + { + find: ",APP_TAG:\"", + replacement: { + match: /APP_TAG:".*?"/, + replace: "APP_TAG:\"BOT\"" + } + } + ], + +}); diff --git a/src/utils/constants.ts b/src/utils/constants.ts index d822c0d9..be1f9277 100644 --- a/src/utils/constants.ts +++ b/src/utils/constants.ts @@ -591,6 +591,10 @@ export const EquicordDevs = Object.freeze({ name: "DaBluLite", id: 582170007505731594n, }, + kvba: { + name: "kvba", + id: 105170831130234880n, + }, } satisfies Record); // iife so #__PURE__ works correctly