mirror of
https://github.com/Vendicated/Vencord.git
synced 2024-09-20 06:30:35 +00:00
Compare commits
37 commits
7eee018887
...
5ff14242fa
Author | SHA1 | Date | |
---|---|---|---|
|
5ff14242fa | ||
|
fddccea8b8 | ||
|
2ae278942e | ||
|
3e12c8758a | ||
|
efbcbec349 | ||
|
35b712da61 | ||
|
c268a3d885 | ||
|
6cca09e571 | ||
|
3a916b37ca | ||
|
39163b3705 | ||
|
ceaaf9ab8a | ||
|
a01ee40591 | ||
|
b4532ad968 | ||
|
0bce276c37 | ||
|
c4f1def5e2 | ||
|
23db98a492 | ||
|
7b8ad34aae | ||
|
90c970c2d0 | ||
|
954a3e87cf | ||
|
f5f6f56738 | ||
|
4b337e30ff | ||
|
24202b0b2f | ||
|
bb026be0fd | ||
|
d2cb9e9863 | ||
|
6e6ee4db68 | ||
|
d8524b087c | ||
|
78fd37a4c6 | ||
|
64f1912bdb | ||
|
3dfd47af53 | ||
|
5daddac821 | ||
|
743c279adc | ||
|
01f5de3793 | ||
|
2b252c4011 | ||
|
cf5886eac6 | ||
|
6c3a4a8f4b | ||
|
c7244d8b26 | ||
|
955232f4d6 |
4 changed files with 102 additions and 1 deletions
61
src/api/ExpressionPickerTabs.tsx
Normal file
61
src/api/ExpressionPickerTabs.tsx
Normal file
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import ErrorBoundary from "@components/ErrorBoundary";
|
||||
import { Channel } from "discord-types/general";
|
||||
|
||||
export interface ExpressionPickerButtonProps {
|
||||
id?: string;
|
||||
"aria-controls": string;
|
||||
"aria-selected": boolean;
|
||||
isActive: boolean;
|
||||
viewType: string;
|
||||
children: string | JSX.Element;
|
||||
autoFocus?: boolean;
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
export interface ExpressionPickerPanelProps {
|
||||
selectedTab: string;
|
||||
channel: Channel;
|
||||
}
|
||||
|
||||
export type ExpressionPickerButtonComponent = (props: ExpressionPickerButtonProps) => JSX.Element | null;
|
||||
export type ExpressionPickerPanelComponent = (props: ExpressionPickerPanelProps) => JSX.Element | null;
|
||||
|
||||
|
||||
export interface ExpressionPickerTabItem {
|
||||
tab: string,
|
||||
Component: ExpressionPickerPanelComponent;
|
||||
autoFocus?: boolean;
|
||||
}
|
||||
|
||||
const ExpressionPickerComponents = new Map<string, ExpressionPickerTabItem>();
|
||||
|
||||
|
||||
export const addExpressionPickerTabButton = (id: string, tab: string, PanelComponent: ExpressionPickerPanelComponent, autoFocus?: boolean) => ExpressionPickerComponents.set(id, { tab: tab, Component: PanelComponent, autoFocus: autoFocus });
|
||||
export const removeExpressionPickerTabButton = (id: string) => ExpressionPickerComponents.delete(id);
|
||||
|
||||
|
||||
export function* RenderTabButtons(ExpressionPickerButtonComponent: ExpressionPickerButtonComponent, selectedTab: string) {
|
||||
for (const [id, { tab }] of ExpressionPickerComponents) {
|
||||
yield (<ErrorBoundary><ExpressionPickerButtonComponent
|
||||
id={id + "-picker-tab"}
|
||||
aria-controls={id + "-picker-tab-panel"}
|
||||
aria-selected={id === selectedTab}
|
||||
viewType={id}
|
||||
isActive={id === selectedTab}
|
||||
>{tab}</ExpressionPickerButtonComponent></ErrorBoundary>);
|
||||
}
|
||||
}
|
||||
|
||||
export function* TabPanels(selectedTab: string, channel: Channel) {
|
||||
for (const [id, { Component }] of ExpressionPickerComponents) {
|
||||
if (id !== selectedTab) { continue; }
|
||||
const PanelComponent: ExpressionPickerPanelComponent = Component;
|
||||
yield (<ErrorBoundary><PanelComponent selectedTab={selectedTab} channel={channel} /></ErrorBoundary>);
|
||||
}
|
||||
}
|
|
@ -21,6 +21,7 @@ import * as $ChatButtons from "./ChatButtons";
|
|||
import * as $Commands from "./Commands";
|
||||
import * as $ContextMenu from "./ContextMenu";
|
||||
import * as $DataStore from "./DataStore";
|
||||
import * as $ExpressionPickerTabs from "./ExpressionPickerTabs";
|
||||
import * as $MemberListDecorators from "./MemberListDecorators";
|
||||
import * as $MessageAccessories from "./MessageAccessories";
|
||||
import * as $MessageDecorations from "./MessageDecorations";
|
||||
|
@ -119,6 +120,11 @@ export const ChatButtons = $ChatButtons;
|
|||
export const MessageUpdater = $MessageUpdater;
|
||||
|
||||
/**
|
||||
* An API allowing you to get an user setting
|
||||
* An API allowing you to add panels to the expression picker
|
||||
*/
|
||||
export const ExpressionPickerTabs = $ExpressionPickerTabs;
|
||||
|
||||
/**
|
||||
* An API allowing you to get an user setting
|
||||
*/
|
||||
export const UserSettings = $UserSettings;
|
||||
|
|
30
src/plugins/_api/expressionPickerTabs.ts
Normal file
30
src/plugins/_api/expressionPickerTabs.ts
Normal file
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* Vencord, a Discord client mod
|
||||
* Copyright (c) 2024 Vendicated and contributors
|
||||
* SPDX-License-Identifier: GPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import { Devs } from "@utils/constants";
|
||||
import definePlugin from "@utils/types";
|
||||
|
||||
|
||||
export default definePlugin({
|
||||
name: "ExpressionPickerTabsAPI",
|
||||
description: "an API to add panels to the expression picker",
|
||||
authors: [Devs.iamme],
|
||||
patches: [
|
||||
{
|
||||
find: ".EXPRESSION_PICKER_CATEGORIES_A11Y_LABEL",
|
||||
replacement: [
|
||||
{
|
||||
match: /\.jsx\)\((\i),\{id:\i\.E\i,.+?,"aria-selected":(\i)===\i\.\i\.EMOJI.+?,viewType:(\i).+?\}\)/,
|
||||
replace: "$&,...Vencord.Api.ExpressionPickerTabs.RenderTabButtons($1, $2)"
|
||||
},
|
||||
{
|
||||
match: /null,(\i)===\i\.\i\.EMOJI\?.{0,55}channel:(\i),.+?\):null/,
|
||||
replace: "$&,...Vencord.Api.ExpressionPickerTabs.TabPanels($1, $2)"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
});
|
|
@ -475,6 +475,10 @@ export const Devs = /* #__PURE__*/ Object.freeze({
|
|||
name: "Sqaaakoi",
|
||||
id: 259558259491340288n
|
||||
},
|
||||
iamme: {
|
||||
name: "i am me",
|
||||
id: 984392761929256980n
|
||||
},
|
||||
Byron: {
|
||||
name: "byeoon",
|
||||
id: 1167275288036655133n
|
||||
|
|
Loading…
Reference in a new issue