From c981325fb345f89325e4a59edc827085239ce0c5 Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Sat, 25 Nov 2023 17:00:10 +0000 Subject: [PATCH] fix: colorpicker (sorta) this now uses the lazy-loaded colorpicker, but this only works if said colorpicker has already been loaded. need to force load before anything. --- .../components/SettingColorComponent.tsx | 52 ++----------------- .../ThemeSettings/components/colorStyles.css | 23 -------- 2 files changed, 5 insertions(+), 70 deletions(-) diff --git a/src/components/ThemeSettings/components/SettingColorComponent.tsx b/src/components/ThemeSettings/components/SettingColorComponent.tsx index 16c11af74..6adca4fa4 100644 --- a/src/components/ThemeSettings/components/SettingColorComponent.tsx +++ b/src/components/ThemeSettings/components/SettingColorComponent.tsx @@ -7,61 +7,21 @@ import "./colorStyles.css"; import { classNameFactory } from "@api/Styles"; -import { LazyComponent } from "@utils/react"; -import { find, findByCodeLazy } from "@webpack"; -import { Forms, Popout, useMemo, useState } from "@webpack/common"; +import { findByCodeLazy, findComponentByCodeLazy } from "@webpack"; +import { Forms, useMemo, useState } from "@webpack/common"; interface ColorPickerProps { - value: number | null; + color: number | null; showEyeDropper?: boolean; onChange(value: number | null): void; - onClose?(): void; } -const ColorPickerModal = LazyComponent(() => find(m => m?.type?.toString?.().includes(".showEyeDropper"))); +const ColorPicker = findComponentByCodeLazy(".Messages.USER_SETTINGS_PROFILE_COLOR_SELECT_COLOR"); // TinyColor is completely unmangled and it's duplicated in two modules! Fun! const TinyColor: tinycolor.Constructor = findByCodeLazy("this._gradientType="); const cl = classNameFactory("vc-usercss-settings-color-"); -// const EditPencil = findByCodeLazy("M19.2929 9.8299L19.9409 9.18278C21.353 7.77064", '["color","height","width"]'); - -function EditPencil({ className, color }) { - return ( - - - - ); -} - -function ColorPicker(props: ColorPickerProps & { width: number; height: number; }) { - const [color, setColor] = useState(props.value); - - const correctedColor = color ? `#${color.toString(16).padStart(6, "0")}` : "#000000"; - - return ( - ( - { setColor(value); props.onChange(value); }} showEyeDropper={props.showEyeDropper} /> - )} - > - {popoutProps => ( -
- -
- )} -
- ); -} - interface Props { label: string; name: string; @@ -86,10 +46,8 @@ export function SettingColorComponent({ label, name, themeSettings }: Props) {
{label}
diff --git a/src/components/ThemeSettings/components/colorStyles.css b/src/components/ThemeSettings/components/colorStyles.css index b76f0bedd..8b7bfc518 100644 --- a/src/components/ThemeSettings/components/colorStyles.css +++ b/src/components/ThemeSettings/components/colorStyles.css @@ -1,22 +1,3 @@ -.vc-usercss-settings-color-swatch { - display: flex; - align-items: center; - justify-content: center; - box-sizing: border-box; - position: relative; - border: 1px solid; - border-radius: 4px; - cursor: pointer; -} - -.vc-usercss-settings-color-swatch-pencil { - position: absolute; - top: 4px; - right: 4px; - width: 14px; - height: 14px; -} - .vc-usercss-settings-color-swatch-row { display: flex; flex-direction: row; @@ -36,7 +17,3 @@ font-weight: 500; word-wrap: break-word; } - -.vc-usercss-settings-color-swatch-row > .vc-usercss-settings-color-swatch { - flex: 0 0 auto; -}