From 4c816d78a79361704efe958d7d9c0ab4d4c9f9df Mon Sep 17 00:00:00 2001 From: Steven Crader Date: Sun, 5 Nov 2023 22:21:20 -0800 Subject: [PATCH] Add option to disable alternate colors in chat --- src/components/open-chat/open-chat.scss | 24 ++++++++++++++++-------- src/content.ts | 5 ++++- src/message-options.ts | 5 ++++- src/pages/options/options.html | 11 +++++++++++ src/pages/options/options.ts | 3 +++ src/theme.ts | 17 ++++++++++++++++- src/types/option-types.ts | 5 +++++ 7 files changed, 59 insertions(+), 11 deletions(-) diff --git a/src/components/open-chat/open-chat.scss b/src/components/open-chat/open-chat.scss index 9743762..d466783 100644 --- a/src/components/open-chat/open-chat.scss +++ b/src/components/open-chat/open-chat.scss @@ -56,12 +56,16 @@ &.chat-history--subscribed { background-image: linear-gradient(to right, var(--light-subscribed), var(--light-accent)); } + } - &:nth-child(odd) { - background-color: var(--light-accent2); + &.alternate-colors { + .chat-history--row { + &:nth-child(odd) { + background-color: var(--light-accent2); - &.chat-history--subscribed { - background-image: linear-gradient(to right, var(--light-subscribed), var(--light-accent2)); + &.chat-history--subscribed { + background-image: linear-gradient(to right, var(--light-subscribed), var(--light-accent2)); + } } } } @@ -72,12 +76,16 @@ &.chat-history--subscribed { background-image: linear-gradient(to right, var(--dark-subscribed), var(--dark-accent)); } + } - &:nth-child(odd) { - background-color: var(--dark-accent2); + &.alternate-colors { + .chat-history--row { + &:nth-child(odd) { + background-color: var(--dark-accent2); - &.chat-history--subscribed { - background-image: linear-gradient(to right, var(--dark-subscribed), var(--dark-accent2)); + &.chat-history--subscribed { + background-image: linear-gradient(to right, var(--dark-subscribed), var(--dark-accent2)); + } } } } diff --git a/src/content.ts b/src/content.ts index b8708dc..3ed6563 100644 --- a/src/content.ts +++ b/src/content.ts @@ -8,6 +8,7 @@ import { replacePageContent } from "./rantstatspage" import { registerRumbleThemeObserver, registerSystemColorSchemeWatcher, + updateAlternateColorsStyle, updateChatThemeStyle, updateThemeStyle, } from "./theme" @@ -32,7 +33,9 @@ registerSystemColorSchemeWatcher() registerRumbleThemeObserver() updateChatThemeStyle() -getOptions().then() +getOptions().then((options: Options) => { + updateAlternateColorsStyle(options?.alternateColors) +}) // run clean history at the beginning of each load cleanHistory().then() diff --git a/src/message-options.ts b/src/message-options.ts index 96c06e6..8483ba2 100644 --- a/src/message-options.ts +++ b/src/message-options.ts @@ -1,5 +1,5 @@ import { setLastSortOrder, sortChats } from "./components/rants/rant" -import { updateThemeStyle } from "./theme" +import { updateAlternateColorsStyle, updateThemeStyle } from "./theme" import { Messages } from "./types/messages" import { Options, SortOrder, Theme } from "./types/option-types" @@ -18,4 +18,7 @@ export const handleUpdateOptions = (options: Options): void => { if (options?.theme !== undefined) { updateThemeStyle(options.theme as Theme) } + if (options?.alternateColors !== undefined) { + updateAlternateColorsStyle(options.alternateColors) + } } diff --git a/src/pages/options/options.html b/src/pages/options/options.html index f081aea..b00416c 100644 --- a/src/pages/options/options.html +++ b/src/pages/options/options.html @@ -66,6 +66,17 @@

RantStats Extension Options

+
+
+ +

Alternate colors of messages in chat

+
+ +
+ +
+
+