diff --git a/src/backend/overlay-widgets/builtin-types/chat/chat.ts b/src/backend/overlay-widgets/builtin-types/chat/chat.ts index 785364931..7930d38c3 100644 --- a/src/backend/overlay-widgets/builtin-types/chat/chat.ts +++ b/src/backend/overlay-widgets/builtin-types/chat/chat.ts @@ -23,6 +23,8 @@ export type ChatWidgetSettings = { messageExitAnimation?: Animation; messageStyle: "compact" | "modern"; chatOrder: "normal" | "reversed"; + /** The type of the chat (vertical or horizontal, undefined = vertical) */ + chatType: "vertical" | "horizontal" | undefined; actionDisplayFormat: "modern" | "classic"; highlightStyle: "normal" | "highlighted"; highlightColor?: string; @@ -215,17 +217,32 @@ export const chat: OverlayWidgetType = { { value: "normal", label: "Normal", - description: "New messages will appear at the bottom of the chat feed", + description: "New messages will appear at the end of the chat feed (bottom for vertical, right for horizontal)", iconClass: "fa-sort-amount-down-alt" }, { value: "reversed", label: "Reversed", - description: "New messages will appear at the top of the chat feed", + description: "New messages will appear at the start of the chat feed (top for vertical, left for horizontal)", iconClass: "fa-sort-amount-up" } ] }, + { + name: "chatType", + title: "Chat Type", + description: "The type of chat widget", + type: "radio-cards", + default: "vertical", + options: [{ + value: "vertical", label: "Vertical", iconClass: "fa-arrows-alt-v" + }, { + value: "horizontal", label: "Horizontal", iconClass: "fa-arrows-alt-h" + }], + settings: { + gridColumns: 2 + } + }, { name: "actionDisplayFormat", title: "Action Display Format", @@ -331,6 +348,12 @@ export const chat: OverlayWidgetType = { }], settings: { gridColumns: 2 + }, + showIf: { + chatType: [ + "vertical", + undefined + ] } }, { @@ -894,6 +917,9 @@ export const chat: OverlayWidgetType = { default: switch (config.settings.verticalAlignment) { case "bottom": + if (config.settings.chatType === "horizontal") { + anchorToBottom = true; + } height = "100%"; maxHeight = "100%"; justifyContent = "end"; @@ -907,16 +933,26 @@ export const chat: OverlayWidgetType = { break; } + let flexDirection = config.settings.chatType === "horizontal" ? "row" : "column"; + flexDirection = config.settings.chatOrder === "reversed" ? `${flexDirection}-reverse` : flexDirection; + + const horizontalAlignment = config.settings.chatType === "horizontal" ? "left" : config.settings.horizontalAlignment; + const chatContainerStyles: Record = { "display": "flex", - "flex-direction": config.settings.chatOrder === "reversed" ? "column-reverse" : "column", - "align-items": config.settings.horizontalAlignment === "right" ? "end" : "start", + "flex-direction": flexDirection, + "align-items": horizontalAlignment === "right" ? "end" : "start", "justify-content": justifyContent, "height": height, "width": "100%", - "text-align": config.settings.horizontalAlignment + "text-align": horizontalAlignment }; + if (config.settings.chatType === "horizontal") { + chatContainerStyles["text-wrap"] = "nowrap"; + chatContainerStyles["align-items"] = "end"; + } + if (!!maxHeight?.length) { chatContainerStyles["max-height"] = maxHeight; } @@ -929,7 +965,7 @@ export const chat: OverlayWidgetType = { const messageRootContainerStyles: Record = { "display": "flex", "gap": "10px", - "flex-direction": config.settings.horizontalAlignment === "right" + "flex-direction": horizontalAlignment === "right" ? "row-reverse" : "row" }; @@ -1006,6 +1042,10 @@ export const chat: OverlayWidgetType = { "font-style": config.settings?.actionDisplayFormat === "classic" ? "normal" : "italic" }; + const chatMargin = config.settings.chatType === "horizontal" ? + config.settings.chatOrder === "reversed" ? "right" : "left" : + config.settings.chatOrder === "reversed" ? "bottom" : "top"; + const styleMarkup = `