Skip to content

Commit

Permalink
improve settings ui (again)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vendicated committed Jul 2, 2024
1 parent 7749206 commit 00125ee
Show file tree
Hide file tree
Showing 10 changed files with 251 additions and 140 deletions.
8 changes: 7 additions & 1 deletion .stylelintrc.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
{
"extends": "stylelint-config-standard",
"rules": {
"indentation": 4
"indentation": 4,
"selector-class-pattern": [
"^[a-z][a-zA-Z0-9]*(-[a-z0-9][a-zA-Z0-9]*)*$",
{
"message": "Expected class selector to be kebab-case with camelCase segments"
}
]
}
}
5 changes: 3 additions & 2 deletions src/components/VencordSettings/ThemesTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Button, Card, Forms, React, showToast, TabBar, TextArea, useEffect, use
import type { ComponentType, Ref, SyntheticEvent } from "react";

import { AddonCard } from "./AddonCard";
import { QuickActionCard } from "./quickActions";
import { SettingsTab, wrapTab } from "./shared";

type FileInput = ComponentType<{
Expand Down Expand Up @@ -213,7 +214,7 @@ function ThemesTab() {
</Card>

<Forms.FormSection title="Local Themes">
<Card className="vc-settings-quick-actions-card">
<QuickActionCard>
<>
{IS_WEB ?
(
Expand Down Expand Up @@ -266,7 +267,7 @@ function ThemesTab() {
</Button>
)}
</>
</Card>
</QuickActionCard>

<div className={cl("grid")}>
{userThemes?.map(theme => (
Expand Down
77 changes: 30 additions & 47 deletions src/components/VencordSettings/VencordTab.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,16 @@ import { useSettings } from "@api/Settings";
import { classNameFactory } from "@api/Styles";
import DonateButton from "@components/DonateButton";
import { openPluginModal } from "@components/PluginSettings/PluginModal";
import { gitRemote } from "@shared/vencordUserAgent";
import { Margins } from "@utils/margins";
import { identity } from "@utils/misc";
import { relaunch, showItemInFolder } from "@utils/native";
import { useAwaiter } from "@utils/react";
import { Button, Card, Forms, React, Select, Switch, TooltipContainer } from "@webpack/common";
import { ComponentType } from "react";
import { Button, Card, Forms, React, Select, Switch } from "@webpack/common";

import { Flex, FolderIcon, GithubIcon, LogIcon, PaintbrushIcon, RestartIcon } from "..";
import { openNotificationSettingsModal } from "./NotificationSettings";
import { QuickAction, QuickActionCard } from "./quickActions";
import { SettingsTab, wrapTab } from "./shared";

const cl = classNameFactory("vc-settings-");
Expand All @@ -41,17 +42,6 @@ type KeysOfType<Object, Type> = {
[K in keyof Object]: Object[K] extends Type ? K : never;
}[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() {
const [settingsDir, , settingsDirPending] = useAwaiter(VencordNative.settings.getSettingsDir, {
Expand Down Expand Up @@ -111,44 +101,37 @@ function VencordSettings() {
<SettingsTab title="Vencord Settings">
<DonateCard image={donateImage} />
<Forms.FormSection title="Quick Actions">
<Card className={cl("quick-actions-card")}>
<Button
onClick={openNotificationLogModal}
look={Button.Looks.BLANK}
>
<NotificationLogIcon />
</Button>
<Button
onClick={() => VencordNative.quickCss.openEditor()}
look={Button.Looks.BLANK}
>
<QuickCssIcon />
</Button>
<QuickActionCard>
<QuickAction
Icon={LogIcon}
text="Notification Log"
action={openNotificationLogModal}
/>
<QuickAction
Icon={PaintbrushIcon}
text="Edit QuickCSS"
action={() => VencordNative.quickCss.openEditor()}
/>
{!IS_WEB && (
<Button
onClick={relaunch}
look={Button.Looks.BLANK}
>
<RelaunchIcon />
</Button>
<QuickAction
Icon={RestartIcon}
text="Relaunch Discord"
action={relaunch}
/>
)}
{!IS_WEB && (
<Button
onClick={() => showItemInFolder(settingsDir)}
look={Button.Looks.BLANK}
disabled={settingsDirPending}
>
<OpenSettingsDirIcon />
</Button>
<QuickAction
Icon={FolderIcon}
text="Open Settings Folder"
action={() => showItemInFolder(settingsDir)}
/>
)}
<Button
onClick={() => VencordNative.native.openExternal("https://github.com/Vendicated/Vencord")}
look={Button.Looks.BLANK}
disabled={settingsDirPending}
>
<OpenGithubIcon />
</Button>
</Card>
<QuickAction
Icon={GithubIcon}
text="View Source Code"
action={() => VencordNative.native.openExternal("https://github.com/" + gitRemote)}
/>
</QuickActionCard>
</Forms.FormSection>

<Forms.FormDivider />
Expand Down
35 changes: 35 additions & 0 deletions src/components/VencordSettings/quickActions.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.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 {
background: var(--background-secondary-alt);
outline: 2px solid var(--focus-primary);
outline-offset: 2px;
}

.vc-settings-quickActions-img {
width: 24px;
height: 24px;
}
32 changes: 32 additions & 0 deletions src/components/VencordSettings/quickActions.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* 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 { ComponentType, PropsWithChildren } from "react";

const cl = classNameFactory("vc-settings-quickActions-");

export function QuickAction(props: { Icon: ComponentType<{ className?: string; }>; text: string; action: () => void; }) {
const { Icon, action, text } = props;

return (
<button className={cl("pill")} onClick={action}>
<Icon className={cl("img")} />
{text}
</button>
);
}

export function QuickActionCard(props: PropsWithChildren) {
return (
<Card className={cl("card")}>
{props.children}
</Card>
);
}
20 changes: 0 additions & 20 deletions src/components/VencordSettings/settingsStyles.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@
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 {
display: flex;
flex-direction: row;
Expand Down
2 changes: 1 addition & 1 deletion src/utils/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { DevsById } from "./constants";
* Calls .join(" ") on the arguments
* classes("one", "two") => "one two"
*/
export function classes(...classes: Array<string | null | undefined>) {
export function classes(...classes: Array<string | null | undefined | false>) {
return classes.filter(Boolean).join(" ");
}

Expand Down
62 changes: 61 additions & 1 deletion src/webpack/common/types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/

import { Guild, GuildMember } from "discord-types/general";
import { Guild, GuildMember, User } from "discord-types/general";
import type { ReactNode } from "react";
import { LiteralUnion } from "type-fest";

Expand Down Expand Up @@ -256,3 +256,63 @@ export interface PopoutActions {
close(key: string): void;
setAlwaysOnTop(key: string, alwaysOnTop: boolean): void;
}

export type UserNameUtilsTagInclude = LiteralUnion<"auto" | "always" | "never", string>;
export interface UserNameUtilsTagOptions {
forcePomelo?: boolean;
identifiable?: UserNameUtilsTagInclude;
decoration?: UserNameUtilsTagInclude;
mode?: "full" | "username";
}

export interface UsernameUtils {
getGlobalName(user: User): string;
getFormattedName(user: User, useTagInsteadOfUsername?: boolean): string;
getName(user: User): string;
useName(user: User): string;
getUserTag(user: User, options?: UserNameUtilsTagOptions): string;
useUserTag(user: User, options?: UserNameUtilsTagOptions): string;


useDirectMessageRecipient: any;
humanizeStatus: any;
}

export class DisplayProfile {
userId: string;
banner?: string;
bio?: string;
pronouns?: string;
accentColor?: number;
themeColors?: number[];
popoutAnimationParticleType?: any;
profileEffectId?: string;
_userProfile?: any;
_guildMemberProfile?: any;
canUsePremiumProfileCustomization: boolean;
canEditThemes: boolean;
premiumGuildSince: Date | null;
premiumSince: Date | null;
premiumType?: number;
primaryColor?: number;

getBadges(): Array<{
id: string;
description: string;
icon: string;
link?: string;
}>;
getBannerURL(options: { canAnimate: boolean; size: number; }): string;
getLegacyUsername(): string | null;
hasFullProfile(): boolean;
hasPremiumCustomization(): boolean;
hasThemeColors(): boolean;
isUsingGuildMemberBanner(): boolean;
isUsingGuildMemberBio(): boolean;
isUsingGuildMemberPronouns(): boolean;
}

export interface DisplayProfileUtils {
getDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
useDisplayProfile(userId: string, guildId?: string, customStores?: any): DisplayProfile | null;
}
Loading

0 comments on commit 00125ee

Please sign in to comment.