rename and add setting

This commit is contained in:
sadan 2024-07-29 23:37:53 -04:00
parent 073b561db1
commit 7eeeceea1c
No known key found for this signature in database
4 changed files with 13 additions and 10 deletions

View file

@ -7,9 +7,8 @@
import { closeModal, ModalContent, ModalHeader, ModalRoot, openModalLazy } from "@utils/modal";
import { Button, Menu, Slider, TextInput, useState } from "@webpack/common";
import { folderProp } from ".";
import settings, { folderIconsData } from "./settings";
import { int2rgba, setFolderData } from "./util";
import { folderProp, int2rgba, setFolderData } from "./util";
export function ImageModal(folderProps: folderProp) {
const [data, setData] = useState(((settings.store.folderIcons ?? {}) as folderIconsData)[folderProps.folderId]?.url ?? "");

View file

@ -9,11 +9,8 @@ import definePlugin from "@utils/types";
import { makeContextItem } from "./components";
import settings, { folderIconsData } from "./settings";
import { int2rgba } from "./util";
export interface folderProp {
folderId: string;
folderColor: number;
}
import { folderProp, int2rgba } from "./util";
export default definePlugin({
settings,
name: "CustomFolderIcons",
@ -46,7 +43,7 @@ export default definePlugin({
return (
<div
style={{
backgroundColor: int2rgba(props.folderNode.color, .4),
backgroundColor: int2rgba(props.folderNode.color, +settings.store.solidIcon || .4),
display: "flex",
justifyContent: "center",
alignItems: "center",

View file

@ -14,6 +14,11 @@ export interface folderIcon{
export type folderIconsData = Record<string, folderIcon | null>;
const settings = definePluginSettings({
solidIcon: {
type: OptionType.BOOLEAN,
default: false,
description: "Use a solid background on the background of the image"
},
folderIcons: {
type: OptionType.COMPONENT,
hidden: true,

View file

@ -4,7 +4,6 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
import { folderProp } from ".";
import settings, { folderIcon, folderIconsData } from "./settings";
export async function setFolderData(props: folderProp, newData: folderIcon) {
@ -14,7 +13,10 @@ export async function setFolderData(props: folderProp, newData: folderIcon) {
const folderSettings = (settings.store.folderIcons as folderIconsData);
folderSettings[props.folderId] = newData;
}
export interface folderProp {
folderId: string;
folderColor: number;
}
/**
* @param rgbVal RGB value
* @param alpha alpha bewteen zero and 1