Merge branch 'dev' into edit-users
This commit is contained in:
commit
1bdde745e2
|
@ -392,6 +392,21 @@ export function PaintbrushIcon(props: IconProps) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function PencilIcon(props: IconProps) {
|
||||||
|
return (
|
||||||
|
<Icon
|
||||||
|
{...props}
|
||||||
|
className={classes(props.className, "vc-pencil-icon")}
|
||||||
|
viewBox="0 0 24 24"
|
||||||
|
>
|
||||||
|
<path
|
||||||
|
fill="currentColor"
|
||||||
|
d="m13.96 5.46 4.58 4.58a1 1 0 0 0 1.42 0l1.38-1.38a2 2 0 0 0 0-2.82l-3.18-3.18a2 2 0 0 0-2.82 0l-1.38 1.38a1 1 0 0 0 0 1.42ZM2.11 20.16l.73-4.22a3 3 0 0 1 .83-1.61l7.87-7.87a1 1 0 0 1 1.42 0l4.58 4.58a1 1 0 0 1 0 1.42l-7.87 7.87a3 3 0 0 1-1.6.83l-4.23.73a1.5 1.5 0 0 1-1.73-1.73Z"
|
||||||
|
/>
|
||||||
|
</Icon>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg";
|
const WebsiteIconDark = "/assets/e1e96d89e192de1997f73730db26e94f.svg";
|
||||||
const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg";
|
const WebsiteIconLight = "/assets/730f58bcfd5a57a5e22460c445a0c6cf.svg";
|
||||||
const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg";
|
const GithubIconLight = "/assets/3ff98ad75ac94fa883af5ed62d17c459.svg";
|
||||||
|
|
|
@ -19,21 +19,21 @@
|
||||||
import { useSettings } from "@api/Settings";
|
import { useSettings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import { Flex } from "@components/Flex";
|
import { Flex } from "@components/Flex";
|
||||||
import { DeleteIcon } from "@components/Icons";
|
import { DeleteIcon, FolderIcon, PaintbrushIcon, PencilIcon, PlusIcon, RestartIcon } from "@components/Icons";
|
||||||
import { Link } from "@components/Link";
|
import { Link } from "@components/Link";
|
||||||
import PluginModal from "@components/PluginSettings/PluginModal";
|
import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
||||||
import type { UserThemeHeader } from "@main/themes";
|
import type { UserThemeHeader } from "@main/themes";
|
||||||
import { openInviteModal } from "@utils/discord";
|
import { openInviteModal } from "@utils/discord";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { classes } from "@utils/misc";
|
import { classes } from "@utils/misc";
|
||||||
import { openModal } from "@utils/modal";
|
|
||||||
import { showItemInFolder } from "@utils/native";
|
import { showItemInFolder } from "@utils/native";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import { findByPropsLazy, findLazy } from "@webpack";
|
import { findByPropsLazy, findLazy } from "@webpack";
|
||||||
import { Button, Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
|
import { Card, Forms, React, showToast, TabBar, TextArea, useEffect, useRef, useState } from "@webpack/common";
|
||||||
import type { ComponentType, Ref, SyntheticEvent } from "react";
|
import type { ComponentType, Ref, SyntheticEvent } from "react";
|
||||||
|
|
||||||
import { AddonCard } from "./AddonCard";
|
import { AddonCard } from "./AddonCard";
|
||||||
|
import { QuickAction, QuickActionCard } from "./quickActions";
|
||||||
import { SettingsTab, wrapTab } from "./shared";
|
import { SettingsTab, wrapTab } from "./shared";
|
||||||
|
|
||||||
type FileInput = ComponentType<{
|
type FileInput = ComponentType<{
|
||||||
|
@ -213,60 +213,52 @@ function ThemesTab() {
|
||||||
</Card>
|
</Card>
|
||||||
|
|
||||||
<Forms.FormSection title="Local Themes">
|
<Forms.FormSection title="Local Themes">
|
||||||
<Card className="vc-settings-quick-actions-card">
|
<QuickActionCard>
|
||||||
<>
|
<>
|
||||||
{IS_WEB ?
|
{IS_WEB ?
|
||||||
(
|
(
|
||||||
<Button
|
<QuickAction
|
||||||
size={Button.Sizes.SMALL}
|
text={
|
||||||
disabled={themeDirPending}
|
<span style={{ position: "relative" }}>
|
||||||
>
|
Upload Theme
|
||||||
Upload Theme
|
<FileInput
|
||||||
<FileInput
|
ref={fileInputRef}
|
||||||
ref={fileInputRef}
|
onChange={onFileUpload}
|
||||||
onChange={onFileUpload}
|
multiple={true}
|
||||||
multiple={true}
|
filters={[{ extensions: ["css"] }]}
|
||||||
filters={[{ extensions: ["css"] }]}
|
/>
|
||||||
/>
|
</span>
|
||||||
</Button>
|
}
|
||||||
|
Icon={PlusIcon}
|
||||||
|
/>
|
||||||
) : (
|
) : (
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={() => showItemInFolder(themeDir!)}
|
text="Open Themes Folder"
|
||||||
size={Button.Sizes.SMALL}
|
action={() => showItemInFolder(themeDir!)}
|
||||||
disabled={themeDirPending}
|
disabled={themeDirPending}
|
||||||
>
|
Icon={FolderIcon}
|
||||||
Open Themes Folder
|
/>
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={refreshLocalThemes}
|
text="Load missing Themes"
|
||||||
size={Button.Sizes.SMALL}
|
action={refreshLocalThemes}
|
||||||
>
|
Icon={RestartIcon}
|
||||||
Load missing Themes
|
/>
|
||||||
</Button>
|
<QuickAction
|
||||||
<Button
|
text="Edit QuickCSS"
|
||||||
onClick={() => VencordNative.quickCss.openEditor()}
|
action={() => VencordNative.quickCss.openEditor()}
|
||||||
size={Button.Sizes.SMALL}
|
Icon={PaintbrushIcon}
|
||||||
>
|
/>
|
||||||
Edit QuickCSS
|
|
||||||
</Button>
|
|
||||||
|
|
||||||
{Vencord.Settings.plugins.ClientTheme.enabled && (
|
{Vencord.Settings.plugins.ClientTheme.enabled && (
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={() => openModal(modalProps => (
|
text="Edit ClientTheme"
|
||||||
<PluginModal
|
action={() => openPluginModal(Vencord.Plugins.plugins.ClientTheme)}
|
||||||
{...modalProps}
|
Icon={PencilIcon}
|
||||||
plugin={Vencord.Plugins.plugins.ClientTheme}
|
/>
|
||||||
onRestartNeeded={() => { }}
|
|
||||||
/>
|
|
||||||
))}
|
|
||||||
size={Button.Sizes.SMALL}
|
|
||||||
>
|
|
||||||
Edit ClientTheme
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
</Card>
|
</QuickActionCard>
|
||||||
|
|
||||||
<div className={cl("grid")}>
|
<div className={cl("grid")}>
|
||||||
{userThemes?.map(theme => (
|
{userThemes?.map(theme => (
|
||||||
|
|
|
@ -21,15 +21,16 @@ import { useSettings } from "@api/Settings";
|
||||||
import { classNameFactory } from "@api/Styles";
|
import { classNameFactory } from "@api/Styles";
|
||||||
import DonateButton from "@components/DonateButton";
|
import DonateButton from "@components/DonateButton";
|
||||||
import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
import { openPluginModal } from "@components/PluginSettings/PluginModal";
|
||||||
|
import { gitRemote } from "@shared/vencordUserAgent";
|
||||||
import { Margins } from "@utils/margins";
|
import { Margins } from "@utils/margins";
|
||||||
import { identity } from "@utils/misc";
|
import { identity } from "@utils/misc";
|
||||||
import { relaunch, showItemInFolder } from "@utils/native";
|
import { relaunch, showItemInFolder } from "@utils/native";
|
||||||
import { useAwaiter } from "@utils/react";
|
import { useAwaiter } from "@utils/react";
|
||||||
import { Button, Card, Forms, React, Select, Switch, TooltipContainer } from "@webpack/common";
|
import { Button, Card, Forms, React, Select, Switch } from "@webpack/common";
|
||||||
import { ComponentType } from "react";
|
|
||||||
|
|
||||||
import { Flex, FolderIcon, GithubIcon, LogIcon, PaintbrushIcon, RestartIcon } from "..";
|
import { Flex, FolderIcon, GithubIcon, LogIcon, PaintbrushIcon, RestartIcon } from "..";
|
||||||
import { openNotificationSettingsModal } from "./NotificationSettings";
|
import { openNotificationSettingsModal } from "./NotificationSettings";
|
||||||
|
import { QuickAction, QuickActionCard } from "./quickActions";
|
||||||
import { SettingsTab, wrapTab } from "./shared";
|
import { SettingsTab, wrapTab } from "./shared";
|
||||||
|
|
||||||
const cl = classNameFactory("vc-settings-");
|
const cl = classNameFactory("vc-settings-");
|
||||||
|
@ -41,17 +42,6 @@ type KeysOfType<Object, Type> = {
|
||||||
[K in keyof Object]: Object[K] extends Type ? K : never;
|
[K in keyof Object]: Object[K] extends Type ? K : never;
|
||||||
}[keyof Object];
|
}[keyof Object];
|
||||||
|
|
||||||
const iconWithTooltip = (Icon: ComponentType<{ className?: string; }>, tooltip: string) => () => (
|
|
||||||
<TooltipContainer text={tooltip}>
|
|
||||||
<Icon className={cl("quick-actions-img")} />
|
|
||||||
</TooltipContainer>
|
|
||||||
);
|
|
||||||
|
|
||||||
const NotificationLogIcon = iconWithTooltip(LogIcon, "Open Notification Log");
|
|
||||||
const QuickCssIcon = iconWithTooltip(PaintbrushIcon, "Edit QuickCSS");
|
|
||||||
const RelaunchIcon = iconWithTooltip(RestartIcon, "Relaunch Discord");
|
|
||||||
const OpenSettingsDirIcon = iconWithTooltip(FolderIcon, "Open Settings Directory");
|
|
||||||
const OpenGithubIcon = iconWithTooltip(GithubIcon, "View Vencord's GitHub Repository");
|
|
||||||
|
|
||||||
function VencordSettings() {
|
function VencordSettings() {
|
||||||
const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, {
|
const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, {
|
||||||
|
@ -111,44 +101,37 @@ function VencordSettings() {
|
||||||
<SettingsTab title="Vencord Settings">
|
<SettingsTab title="Vencord Settings">
|
||||||
<DonateCard image={donateImage} />
|
<DonateCard image={donateImage} />
|
||||||
<Forms.FormSection title="Quick Actions">
|
<Forms.FormSection title="Quick Actions">
|
||||||
<Card className={cl("quick-actions-card")}>
|
<QuickActionCard>
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={openNotificationLogModal}
|
Icon={LogIcon}
|
||||||
look={Button.Looks.BLANK}
|
text="Notification Log"
|
||||||
>
|
action={openNotificationLogModal}
|
||||||
<NotificationLogIcon />
|
/>
|
||||||
</Button>
|
<QuickAction
|
||||||
<Button
|
Icon={PaintbrushIcon}
|
||||||
onClick={() => VencordNative.quickCss.openEditor()}
|
text="Edit QuickCSS"
|
||||||
look={Button.Looks.BLANK}
|
action={() => VencordNative.quickCss.openEditor()}
|
||||||
>
|
/>
|
||||||
<QuickCssIcon />
|
|
||||||
</Button>
|
|
||||||
{!IS_WEB && (
|
{!IS_WEB && (
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={relaunch}
|
Icon={RestartIcon}
|
||||||
look={Button.Looks.BLANK}
|
text="Relaunch Discord"
|
||||||
>
|
action={relaunch}
|
||||||
<RelaunchIcon />
|
/>
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
{!IS_WEB && (
|
{!IS_WEB && (
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={() => showItemInFolder(settingsDir)}
|
Icon={FolderIcon}
|
||||||
look={Button.Looks.BLANK}
|
text="Open Settings Folder"
|
||||||
disabled={settingsDirPending}
|
action={() => showItemInFolder(settingsDir)}
|
||||||
>
|
/>
|
||||||
<OpenSettingsDirIcon />
|
|
||||||
</Button>
|
|
||||||
)}
|
)}
|
||||||
<Button
|
<QuickAction
|
||||||
onClick={() => VencordNative.native.openExternal("https://github.com/Vendicated/Vencord")}
|
Icon={GithubIcon}
|
||||||
look={Button.Looks.BLANK}
|
text="View Source Code"
|
||||||
disabled={settingsDirPending}
|
action={() => VencordNative.native.openExternal("https://github.com/" + gitRemote)}
|
||||||
>
|
/>
|
||||||
<OpenGithubIcon />
|
</QuickActionCard>
|
||||||
</Button>
|
|
||||||
</Card>
|
|
||||||
</Forms.FormSection>
|
</Forms.FormSection>
|
||||||
|
|
||||||
<Forms.FormDivider />
|
<Forms.FormDivider />
|
||||||
|
|
34
src/components/VencordSettings/quickActions.css
Normal file
34
src/components/VencordSettings/quickActions.css
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
.vc-settings-quickActions-card {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fill, minmax(200px, max-content));
|
||||||
|
gap: 0.5em;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 0.5em 0;
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-settings-quickActions-pill {
|
||||||
|
all: unset;
|
||||||
|
|
||||||
|
background: var(--background-secondary);
|
||||||
|
color: var(--header-secondary);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 0.5em;
|
||||||
|
padding: 8px 12px;
|
||||||
|
border-radius: 9999px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-settings-quickActions-pill:hover {
|
||||||
|
background: var(--background-secondary-alt);
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-settings-quickActions-pill:focus-visible {
|
||||||
|
outline: 2px solid var(--focus-primary);
|
||||||
|
outline-offset: 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.vc-settings-quickActions-img {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
}
|
39
src/components/VencordSettings/quickActions.tsx
Normal file
39
src/components/VencordSettings/quickActions.tsx
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
* Vencord, a Discord client mod
|
||||||
|
* Copyright (c) 2024 Vendicated and contributors
|
||||||
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import "./quickActions.css";
|
||||||
|
|
||||||
|
import { classNameFactory } from "@api/Styles";
|
||||||
|
import { Card } from "@webpack/common";
|
||||||
|
import type { ComponentType, PropsWithChildren, ReactNode } from "react";
|
||||||
|
|
||||||
|
const cl = classNameFactory("vc-settings-quickActions-");
|
||||||
|
|
||||||
|
export interface QuickActionProps {
|
||||||
|
Icon: ComponentType<{ className?: string; }>;
|
||||||
|
text: ReactNode;
|
||||||
|
action?: () => void;
|
||||||
|
disabled?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function QuickAction(props: QuickActionProps) {
|
||||||
|
const { Icon, action, text, disabled } = props;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<button className={cl("pill")} onClick={action} disabled={disabled}>
|
||||||
|
<Icon className={cl("img")} />
|
||||||
|
{text}
|
||||||
|
</button>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function QuickActionCard(props: PropsWithChildren) {
|
||||||
|
return (
|
||||||
|
<Card className={cl("card")}>
|
||||||
|
{props.children}
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
|
@ -10,26 +10,6 @@
|
||||||
margin-bottom: -2px;
|
margin-bottom: -2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.vc-settings-quick-actions-card {
|
|
||||||
color: var(--text-normal);
|
|
||||||
padding: 1em;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-evenly;
|
|
||||||
gap: 1em;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 1em;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-settings-quick-actions-card button {
|
|
||||||
min-width: unset;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-settings-quick-actions-img {
|
|
||||||
width: 30px;
|
|
||||||
height: 30px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.vc-settings-donate {
|
.vc-settings-donate {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
|
|
Loading…
Reference in a new issue