Skip to content

Commit

Permalink
start rant focus work
Browse files Browse the repository at this point in the history
  • Loading branch information
stevencrader committed Dec 4, 2023
1 parent 4fab5db commit 65a6079
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 55 deletions.
15 changes: 15 additions & 0 deletions src/components/chat-watcher/chat-watcher.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { consoleLog } from "../../log"
import { checkForMutedWordsChat } from "./muted-words"

let preserveMessageData = true
Expand Down Expand Up @@ -61,6 +62,14 @@ const chatObserverCallback = (mutations: Array<MutationRecord>): void => {
})
}

const overlayObserverCallback = (mutations: Array<MutationRecord>): void => {
mutations.forEach((mutation) => {
if (mutation.type === "childList") {
mutation.addedNodes.forEach((node: HTMLLIElement) => newChatReceived(node))
}
})
}

/**
* Register observer for catching new chat messages
*/
Expand All @@ -70,4 +79,10 @@ export const registerChatMessageObserver = (): void => {
const headObserver = new MutationObserver(chatObserverCallback)
headObserver.observe(chatList, { childList: true, attributes: false, subtree: false })
}

const chatOverlay = document.getElementById("chat--rant-overlay")
if (chatOverlay !== null) {
const overlayObserver = new MutationObserver(overlayObserverCallback)
overlayObserver.observe(chatOverlay, { childList: true, attributes: false, subtree: false })
}
}
4 changes: 3 additions & 1 deletion src/components/chat-watcher/muted-words.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ export const addButtonToggle = (

/**
* When clicked, hide self and show hidden text
* @param ev event
*/
showButton.onclick = (): void => {
showButton.onclick = (ev): void => {
if (textNode.classList.contains("hidden")) {
textNode.classList.remove("hidden")
showButton.textContent = buttonTextToHide
} else {
textNode.classList.add("hidden")
showButton.textContent = buttonTextToShow
}
ev.stopImmediatePropagation()
}
}

Expand Down
108 changes: 54 additions & 54 deletions src/components/open-chat/open-chat.scss
Original file line number Diff line number Diff line change
Expand Up @@ -86,60 +86,6 @@
display: none;
}
}

.chat-history--rant {
.show-muted-text-button {
margin: 0 auto 3px auto;
display: block;
}

&[data-level="1"] {
.show-muted-text-button {
background: #4382cb;
color: white;
}
}
&[data-level="2"] {
.show-muted-text-button {
background: #a6d279;
color: black;
}
}
&[data-level="5"] {
.show-muted-text-button {
background: #dfd019;
color: black;
}
}
&[data-level="10"] {
.show-muted-text-button {
background: #dd9520;
color: black;
}
}
&[data-level="20"] {
.show-muted-text-button {
background: #aa0eca;
color: white;
}
}
&[data-level="50"] {
.show-muted-text-button {
background: #8211e5;
color: white;
}
}
&[data-level="100"],
&[data-level="200"],
&[data-level="300"],
&[data-level="400"],
&[data-level="500"] {
.show-muted-text-button {
background: #bb0218;
color: white;
}
}
}
}

.chat-history--notification {
Expand Down Expand Up @@ -204,3 +150,57 @@
}
}
}

.chat-history--rant {
.show-muted-text-button {
margin: 0 auto 3px auto;
display: block;
}

&[data-level="1"] {
.show-muted-text-button {
background: #4382cb;
color: white;
}
}
&[data-level="2"] {
.show-muted-text-button {
background: #a6d279;
color: black;
}
}
&[data-level="5"] {
.show-muted-text-button {
background: #dfd019;
color: black;
}
}
&[data-level="10"] {
.show-muted-text-button {
background: #dd9520;
color: black;
}
}
&[data-level="20"] {
.show-muted-text-button {
background: #aa0eca;
color: white;
}
}
&[data-level="50"] {
.show-muted-text-button {
background: #8211e5;
color: white;
}
}
&[data-level="100"],
&[data-level="200"],
&[data-level="300"],
&[data-level="400"],
&[data-level="500"] {
.show-muted-text-button {
background: #bb0218;
color: white;
}
}
}

0 comments on commit 65a6079

Please sign in to comment.