Skip to content

Added option to hide header above the chat window #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 27, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -81,6 +81,8 @@ REQUIRED data attributes:

- `data-no-sponsor` — Setting this attribute to anything will hide the custom or default sponsor at the bottom of an open chat window.

- `data-no-header` — Setting this attribute hides the header above the chat window.

- `data-sponsor-link` — A clickable link in the sponsor section in the footer of an open chat window.

- `data-sponsor-text` — The text displays in sponsor text in the footer of an open chat window.
17 changes: 10 additions & 7 deletions src/components/ChatWindow/index.jsx
Original file line number Diff line number Diff line change
@@ -35,13 +35,15 @@ export default function ChatWindow({ closeChat, settings, sessionId }) {

return (
<div className="allm-flex allm-flex-col allm-h-full">
<ChatWindowHeader
sessionId={sessionId}
settings={settings}
iconUrl={settings.brandImageUrl}
closeChat={closeChat}
setChatHistory={setChatHistory}
/>
{!settings.noHeader && (
<ChatWindowHeader
sessionId={sessionId}
settings={settings}
iconUrl={settings.brandImageUrl}
closeChat={closeChat}
setChatHistory={setChatHistory}
/>
)}
<div className="allm-flex-grow allm-overflow-y-auto">
<ChatContainer
sessionId={sessionId}
@@ -55,6 +57,7 @@ export default function ChatWindow({ closeChat, settings, sessionId }) {
setChatHistory={setChatHistory}
settings={settings}
sessionId={sessionId}
closeChat={closeChat}
/>
</div>
</div>
26 changes: 23 additions & 3 deletions src/components/ResetChat/index.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import ChatService from "@/models/chatService";
import { useTranslation } from "react-i18next";

export default function ResetChat({ setChatHistory, settings, sessionId }) {
export default function ResetChat({
setChatHistory,
settings,
sessionId,
closeChat,
}) {
const { t } = useTranslation();

const handleChatReset = async () => {
@@ -10,14 +15,29 @@ export default function ResetChat({ setChatHistory, settings, sessionId }) {
};

return (
<div className="allm-w-full allm-flex allm-justify-center">
<div className="allm-w-full allm-flex allm-justify-center allm-gap-x-1 p-0">
<button
style={{ color: "#7A7D7E" }}
className="hover:allm-cursor-pointer allm-border-none allm-text-sm allm-bg-transparent hover:allm-opacity-80 hover:allm-underline"
className="allm-h-fit allm-px-0 hover:allm-cursor-pointer allm-border-none allm-text-sm allm-bg-transparent hover:allm-opacity-80 hover:allm-underline"
onClick={() => handleChatReset()}
>
{settings.resetChatText || t("chat.reset-chat")}
</button>
{settings.noHeader && (
<>
<p className="allm-m-0 allm-h-fit allm-text-sm allm-text-[#7A7D7E]">
|
</p>
<button
type="button"
style={{ color: "#7A7D7E" }}
className="allm-h-fit allm-px-0 hover:allm-cursor-pointer allm-border-none allm-text-sm allm-bg-transparent hover:allm-opacity-80 hover:allm-underline"
onClick={closeChat}
>
Close Chat
</button>
</>
)}
</div>
);
}
1 change: 1 addition & 0 deletions src/hooks/useScriptAttributes.js
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@ const DEFAULT_SETTINGS = {
windowHeight: null, // height of chat window in number:css-prefix
windowWidth: null, // width of chat window in number:css-prefix
textSize: null, // text size in px (number only)
noHeader: null, // If set, hide the header above the chatbox
language: "en", // language of chat interface
sendMessageText: null, // override text for send message button
resetChatText: null, // override text for reset chat button