From d0949452dac82214f493eca9045ad82b70a064b3 Mon Sep 17 00:00:00 2001 From: Ajay Ramachandran Date: Thu, 29 Jul 2021 18:34:31 -0400 Subject: [PATCH] Add close button --- public/content.css | 13 ++++++++++++- src/js-components/chat.ts | 18 +++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/public/content.css b/public/content.css index 2238a2bd..c4c528ae 100644 --- a/public/content.css +++ b/public/content.css @@ -121,7 +121,7 @@ margin-left: 5px; } -.chatNotice { +.sbChatNotice { min-width: 350px; height: 70%; @@ -455,4 +455,15 @@ input::-webkit-inner-spin-button { } .helpButton:hover { filter: brightness(80%); +} + +.sbChatNotice iframe { + height: 32px; + cursor: pointer; + height: 100%; +} + +.sbChatClose { + height: 14px; + cursor: pointer; } \ No newline at end of file diff --git a/src/js-components/chat.ts b/src/js-components/chat.ts index 41725775..ee3e800d 100644 --- a/src/js-components/chat.ts +++ b/src/js-components/chat.ts @@ -9,11 +9,23 @@ export interface ChatConfig { } export function openChat(config: ChatConfig): void { - const chat = document.createElement("iframe"); - chat.src = "https://chat.sponsor.ajay.app/#" + utils.objectToURI("", config, false); - chat.classList.add("chatNotice"); + const chat = document.createElement("div"); + chat.classList.add("sbChatNotice"); chat.style.zIndex = "2000"; + const iframe= document.createElement("iframe"); + iframe.src = "https://chat.sponsor.ajay.app/#" + utils.objectToURI("", config, false); + chat.appendChild(iframe); + + const closeButton = document.createElement("img"); + closeButton.classList.add("sbChatClose"); + closeButton.src = chrome.extension.getURL("icons/close.png"); + closeButton.addEventListener("click", () => { + chat.remove(); + closeButton.remove(); + }); + chat.appendChild(closeButton); + console.log(utils.objectToURI("", config, false)) const referenceNode = utils.findReferenceNode();