mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
bunch of stuff
- fix preview - fix settings - update headers - add readme
This commit is contained in:
parent
a742cc2b53
commit
3b969e55ef
5 changed files with 32 additions and 42 deletions
7
src/plugins/customFolderIcons/README.md
Normal file
7
src/plugins/customFolderIcons/README.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
# CustomFolderIcons
|
||||
|
||||
Allows you to set custom images/svgs as folder icons
|
||||
|
||||
Available as "Change Icon" in the folder context menu
|
||||
|
||||
TODO: upload example images (in *pss#general)
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* Copyright (c) 2024 sadan
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
@ -9,17 +9,20 @@ import { Button, Menu, Slider, TextInput, useState } from "@webpack/common";
|
|||
|
||||
import { folderProp } from ".";
|
||||
import settings, { folderIconsData } from "./settings";
|
||||
import { int2rgba, setFolderUrl } from "./util";
|
||||
import { int2rgba, setFolderData } from "./util";
|
||||
|
||||
export function ImageModal(folderProps: folderProp) {
|
||||
const [data, setData] = useState("");
|
||||
const [data, setData] = useState(((settings.store.folderIcons ?? {}) as folderIconsData)[folderProps.folderId]?.url ?? "");
|
||||
const [size, setSize] = useState(100);
|
||||
return (
|
||||
<>
|
||||
<TextInput onChange={(val, _n) => {
|
||||
setData(val);
|
||||
}}
|
||||
placeholder="https://example.com/image.png"
|
||||
<TextInput
|
||||
// this looks like a horrorshow
|
||||
defaultValue={data}
|
||||
onChange={(val, _n) => {
|
||||
setData(val);
|
||||
}}
|
||||
placeholder="https://example.com/image.png"
|
||||
>
|
||||
</TextInput>
|
||||
<RenderPreview folderProps={folderProps} url={data} size={size} />
|
||||
|
@ -34,13 +37,14 @@ export function ImageModal(folderProps: folderProp) {
|
|||
}}
|
||||
maxValue={200}
|
||||
minValue={25}
|
||||
// [25, 200]
|
||||
markers={Array.apply(0, Array(176)).map((_, i) => i + 25)}
|
||||
stickToMarkers={true}
|
||||
keyboardStep={1}
|
||||
renderMarker={() => null} />
|
||||
</>}
|
||||
<Button onClick={() => {
|
||||
setFolderUrl(folderProps, {
|
||||
setFolderData(folderProps, {
|
||||
url: data,
|
||||
size: size
|
||||
});
|
||||
|
@ -67,18 +71,18 @@ export function ImageModal(folderProps: folderProp) {
|
|||
export function RenderPreview({ folderProps, url, size }: { folderProps: folderProp; url: string; size: number; }) {
|
||||
if (!url) return null;
|
||||
return (
|
||||
<div style={{
|
||||
<div className="test1234" style={{
|
||||
width: "20vh",
|
||||
height: "20vh",
|
||||
borderRadius: "24px",
|
||||
overflow: "hidden",
|
||||
// 16/48
|
||||
borderRadius: "33%",
|
||||
backgroundColor: int2rgba(folderProps.folderColor, 0.4),
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
}}>
|
||||
<img src={url} width={`${size}%`} height={`${size}%`} style={{
|
||||
// borderRadius: "24px",
|
||||
}} />
|
||||
<img src={url} width={`${size}%`} height={`${size}%`} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* Copyright (c) 2024 sadan
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
|
@ -63,10 +63,3 @@ export default definePlugin({
|
|||
}
|
||||
}
|
||||
});
|
||||
export function handleUpdateError(e: any) {
|
||||
showNotification({
|
||||
title: "CustomFolderIcons: Error",
|
||||
body: "An error has occurred. Check the console for more info."
|
||||
});
|
||||
console.error(e);
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* Copyright (c) 2024 sadan
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { definePluginSettings } from "@api/Settings";
|
||||
import { IPluginOptionComponentProps, OptionType } from "@utils/types";
|
||||
import { OptionType } from "@utils/types";
|
||||
|
||||
export interface folderIcon{
|
||||
url: string,
|
||||
|
@ -17,17 +17,8 @@ const settings = definePluginSettings({
|
|||
folderIcons: {
|
||||
type: OptionType.COMPONENT,
|
||||
hidden: true,
|
||||
description: "guh",
|
||||
component: props => <>
|
||||
<FolderIconsSettings
|
||||
setValue={props.setValue}
|
||||
setError={props.setError}
|
||||
option={props.option}
|
||||
/>
|
||||
</>
|
||||
description: "folder icon settings",
|
||||
component: () => <></>
|
||||
}
|
||||
});
|
||||
export default settings;
|
||||
function FolderIconsSettings(props: IPluginOptionComponentProps): JSX.Element {
|
||||
return <></>;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,18 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* Copyright (c) 2024 sadan
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { folderProp } from ".";
|
||||
import settings, { folderIcon, folderIconsData } from "./settings";
|
||||
|
||||
export async function setFolderUrl(props: folderProp, newData: folderIcon) {
|
||||
// FIXME: https://canary.discord.com/channels/1015060230222131221/1032770730703716362/1256504513125158924
|
||||
export async function setFolderData(props: folderProp, newData: folderIcon) {
|
||||
if(!settings.store.folderIcons){
|
||||
settings.store.folderIcons = {};
|
||||
}
|
||||
const folderSettings = (settings.store.folderIcons as folderIconsData);
|
||||
const data = folderSettings[props.folderId] ?? {} as folderIcon;
|
||||
for (const k in newData){
|
||||
data[k] = newData[k];
|
||||
}
|
||||
folderSettings[props.folderId] = data;
|
||||
folderSettings[props.folderId] = newData;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue