mirror of
https://github.com/Vendicated/Vencord.git
synced 2025-02-24 07:25:10 +00:00
working, but cursed
This commit is contained in:
parent
6e3eb3cc4e
commit
53273b83ba
1 changed files with 37 additions and 33 deletions
|
@ -21,9 +21,10 @@ import ErrorBoundary from "@components/ErrorBoundary";
|
||||||
import { makeRange } from "@components/PluginSettings/components";
|
import { makeRange } from "@components/PluginSettings/components";
|
||||||
import { Devs } from "@utils/constants";
|
import { Devs } from "@utils/constants";
|
||||||
import { Logger } from "@utils/Logger";
|
import { Logger } from "@utils/Logger";
|
||||||
|
import { useForceUpdater } from "@utils/react";
|
||||||
import definePlugin, { OptionType } from "@utils/types";
|
import definePlugin, { OptionType } from "@utils/types";
|
||||||
import { findByCodeLazy } from "@webpack";
|
import { findByCodeLazy } from "@webpack";
|
||||||
import { ChannelStore, GuildMemberStore, GuildStore, useEffect, useState } from "@webpack/common";
|
import { ChannelStore, GuildMemberStore, GuildStore, useEffect, useMemo, useState } from "@webpack/common";
|
||||||
|
|
||||||
import { Color, Contrast } from "./color";
|
import { Color, Contrast } from "./color";
|
||||||
|
|
||||||
|
@ -106,7 +107,7 @@ export function useGetContrastValue() {
|
||||||
}
|
}
|
||||||
export default definePlugin({
|
export default definePlugin({
|
||||||
name: "RoleColorEverywhere",
|
name: "RoleColorEverywhere",
|
||||||
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN, Devs.Kyuuhachi, Devs.jamesbt365],
|
authors: [Devs.KingFish, Devs.lewisakura, Devs.AutumnVN, Devs.Kyuuhachi, Devs.jamesbt365, Devs.sadan],
|
||||||
description: "Adds the top role color anywhere possible",
|
description: "Adds the top role color anywhere possible",
|
||||||
settings,
|
settings,
|
||||||
|
|
||||||
|
@ -236,11 +237,12 @@ export default definePlugin({
|
||||||
},
|
},
|
||||||
|
|
||||||
useMessageColorsStyle(message: any, ref: any | null) {
|
useMessageColorsStyle(message: any, ref: any | null) {
|
||||||
try {
|
|
||||||
const { messageSaturation } = settings.use(["messageSaturation"]);
|
const { messageSaturation } = settings.use(["messageSaturation"]);
|
||||||
const author = useMessageAuthor(message);
|
const author = useMessageAuthor(message);
|
||||||
const contrast = useGetContrastValue();
|
const contrast = useGetContrastValue();
|
||||||
|
const [dep, update] = useForceUpdater(true);
|
||||||
|
return useMemo(() => {
|
||||||
|
try {
|
||||||
if (author.colorString != null && messageSaturation !== 0) {
|
if (author.colorString != null && messageSaturation !== 0) {
|
||||||
if (contrast === 1) {
|
if (contrast === 1) {
|
||||||
const value = `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var({DEFAULT}))`;
|
const value = `color-mix(in oklab, ${author.colorString} ${messageSaturation}%, var({DEFAULT}))`;
|
||||||
|
@ -251,7 +253,8 @@ export default definePlugin({
|
||||||
"--text-muted": value.replace("{DEFAULT}", "--text-muted")
|
"--text-muted": value.replace("{DEFAULT}", "--text-muted")
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (!ref.current) return;
|
// why
|
||||||
|
if (!ref.current) setTimeout(update, 0);
|
||||||
const computed = window.getComputedStyle(ref.current);
|
const computed = window.getComputedStyle(ref.current);
|
||||||
const textNormal = computed.getPropertyValue("--text-normal"),
|
const textNormal = computed.getPropertyValue("--text-normal"),
|
||||||
headerPrimary = computed.getPropertyValue("--header-primary"),
|
headerPrimary = computed.getPropertyValue("--header-primary"),
|
||||||
|
@ -273,6 +276,7 @@ export default definePlugin({
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
}, [author, contrast, ref, messageSaturation, dep]);
|
||||||
},
|
},
|
||||||
|
|
||||||
RoleGroupColor: ErrorBoundary.wrap(({ id, count, title, guildId, label }: { id: string; count: number; title: string; guildId: string; label: string; }) => {
|
RoleGroupColor: ErrorBoundary.wrap(({ id, count, title, guildId, label }: { id: string; count: number; title: string; guildId: string; label: string; }) => {
|
||||||
|
|
Loading…
Add table
Reference in a new issue