forked from Vendicated/Vencord
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into xsoverlay-opts
- Loading branch information
Showing
182 changed files
with
5,864 additions
and
1,879 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.vc-chatbar-button { | ||
display: flex; | ||
align-items: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
/* | ||
* Vencord, a Discord client mod | ||
* Copyright (c) 2024 Vendicated and contributors | ||
* SPDX-License-Identifier: GPL-3.0-or-later | ||
*/ | ||
|
||
import "./ChatButton.css"; | ||
|
||
import ErrorBoundary from "@components/ErrorBoundary"; | ||
import { Logger } from "@utils/Logger"; | ||
import { waitFor } from "@webpack"; | ||
import { Button, ButtonLooks, ButtonWrapperClasses, Tooltip } from "@webpack/common"; | ||
import { Channel } from "discord-types/general"; | ||
import { HTMLProps, MouseEventHandler, ReactNode } from "react"; | ||
|
||
let ChannelTextAreaClasses: Record<"button" | "buttonContainer", string>; | ||
waitFor(["buttonContainer", "channelTextArea"], m => ChannelTextAreaClasses = m); | ||
|
||
export interface ChatBarProps { | ||
channel: Channel; | ||
disabled: boolean; | ||
isEmpty: boolean; | ||
type: { | ||
analyticsName: string; | ||
attachments: boolean; | ||
autocomplete: { | ||
addReactionShortcut: boolean, | ||
forceChatLayer: boolean, | ||
reactions: boolean; | ||
}, | ||
commands: { | ||
enabled: boolean; | ||
}, | ||
drafts: { | ||
type: number, | ||
commandType: number, | ||
autoSave: boolean; | ||
}, | ||
emojis: { | ||
button: boolean; | ||
}, | ||
gifs: { | ||
button: boolean, | ||
allowSending: boolean; | ||
}, | ||
gifts: { | ||
button: boolean; | ||
}, | ||
permissions: { | ||
requireSendMessages: boolean; | ||
}, | ||
showThreadPromptOnReply: boolean, | ||
stickers: { | ||
button: boolean, | ||
allowSending: boolean, | ||
autoSuggest: boolean; | ||
}, | ||
users: { | ||
allowMentioning: boolean; | ||
}, | ||
submit: { | ||
button: boolean, | ||
ignorePreference: boolean, | ||
disableEnterToSubmit: boolean, | ||
clearOnSubmit: boolean, | ||
useDisabledStylesOnSubmit: boolean; | ||
}, | ||
uploadLongMessages: boolean, | ||
upsellLongMessages: { | ||
iconOnly: boolean; | ||
}, | ||
showCharacterCount: boolean, | ||
sedReplace: boolean; | ||
}; | ||
} | ||
|
||
export type ChatBarButton = (props: ChatBarProps & { isMainChat: boolean; }) => JSX.Element | null; | ||
|
||
const buttonFactories = new Map<string, ChatBarButton>(); | ||
const logger = new Logger("ChatButtons"); | ||
|
||
export function _injectButtons(buttons: ReactNode[], props: ChatBarProps) { | ||
if (props.disabled) return; | ||
|
||
for (const [key, Button] of buttonFactories) { | ||
buttons.push( | ||
<ErrorBoundary noop key={key} onError={e => logger.error(`Failed to render ${key}`, e.error)}> | ||
<Button {...props} isMainChat={props.type.analyticsName === "normal"} /> | ||
</ErrorBoundary> | ||
); | ||
} | ||
} | ||
|
||
export const addChatBarButton = (id: string, button: ChatBarButton) => buttonFactories.set(id, button); | ||
export const removeChatBarButton = (id: string) => buttonFactories.delete(id); | ||
|
||
export interface ChatBarButtonProps { | ||
children: ReactNode; | ||
tooltip: string; | ||
onClick: MouseEventHandler<HTMLButtonElement>; | ||
onContextMenu?: MouseEventHandler<HTMLButtonElement>; | ||
buttonProps?: Omit<HTMLProps<HTMLButtonElement>, "size" | "onClick" | "onContextMenu">; | ||
} | ||
export const ChatBarButton = ErrorBoundary.wrap((props: ChatBarButtonProps) => { | ||
return ( | ||
<Tooltip text={props.tooltip}> | ||
{({ onMouseEnter, onMouseLeave }) => ( | ||
<div className={`expression-picker-chat-input-button ${ChannelTextAreaClasses?.buttonContainer ?? ""} vc-chatbar-button`}> | ||
<Button | ||
aria-label={props.tooltip} | ||
size="" | ||
look={ButtonLooks.BLANK} | ||
onMouseEnter={onMouseEnter} | ||
onMouseLeave={onMouseLeave} | ||
innerClassName={`${ButtonWrapperClasses.button} ${ChannelTextAreaClasses?.button}`} | ||
onClick={props.onClick} | ||
onContextMenu={props.onContextMenu} | ||
{...props.buttonProps} | ||
> | ||
<div className={ButtonWrapperClasses.buttonWrapper}> | ||
{props.children} | ||
</div> | ||
</Button> | ||
</div> | ||
)} | ||
</Tooltip> | ||
); | ||
}, { noop: true }); |
Oops, something went wrong.