diff --git a/langs/en-ca.json b/langs/en-ca.json index 4c2b17f..adb0acb 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -4,6 +4,10 @@ "startSidebarExpanded": { "name": "Start Sidebar Expanded", "hint": "(v13+) Starts the right-hand sidebar expanded when logging in." + }, + "chatSidebarBackground": { + "name": "Chat Background", + "hint": "(v13+) Adds a background to the chat tab of the right-hand sidebar." } } } diff --git a/module/consts.mjs b/module/consts.mjs index 9286d27..9db4ce4 100644 --- a/module/consts.mjs +++ b/module/consts.mjs @@ -1,5 +1,5 @@ export const __ID = `oft`; export function inDev() { - return game.modules.get(__ID).flags.inDev; + return game.modules.get(__ID).flags.inDev ?? false; }; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 93489c9..9e301b5 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -1,8 +1,10 @@ import { __ID } from "../consts.mjs"; +import { chatSidebarBackground } from "../settings/chatSidebarBackground.mjs"; import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs"; Hooks.once(`init`, () => { console.log(`${__ID} | Initializing`); startSidebarExpanded.register(); + chatSidebarBackground.register(); }); diff --git a/module/hooks/renderSidebar.mjs b/module/hooks/renderSidebar.mjs index 9d8e2dd..6ba60a8 100644 --- a/module/hooks/renderSidebar.mjs +++ b/module/hooks/renderSidebar.mjs @@ -1,9 +1,15 @@ +import { __ID, inDev } from "../consts.mjs"; import { startSidebarExpanded } from "../settings/startSidebarExpanded.mjs"; -Hooks.once(`renderSidebar`, (app, _element, _context, _options) => { +// #region Once +Hooks.once(`renderSidebar`, (app) => { // MARK: Sidebar Expansion if (startSidebarExpanded.value()) { + if (inDev()) { + console.log(`${__ID} | setting:startSidebarExpanded | Expanding Sidebar`); + } app.toggleExpanded(true); - } + }; }); +// #endregion Once diff --git a/module/settings/chatSidebarBackground.mjs b/module/settings/chatSidebarBackground.mjs new file mode 100644 index 0000000..99eaa97 --- /dev/null +++ b/module/settings/chatSidebarBackground.mjs @@ -0,0 +1,35 @@ +import { __ID, inDev } from "../consts.mjs"; + +const key = `chatSidebarBackground`; + +const config = { + name: `OFT.setting.${key}.name`, + hint: `OFT.setting.${key}.hint`, + scope: `user`, + type: Boolean, + default: true, + config: true, + requiresReload: false, + onChange: (newValue) => { + if (inDev()) { + console.log(`${__ID} | setting:${key} | Setting to: ${newValue}`); + }; + document.body.classList.toggle(`oft-${key}`, newValue); + }, +}; + +export const chatSidebarBackground = { + value() { + return game.settings.get(__ID, key); + }, + register() { + game.settings.register(__ID, key, config); + + if (this.value()) { + if (inDev()) { + console.log(`${__ID} | setting:${key} | Adding chat background`); + }; + document.body.classList.add(`oft-${key}`); + }; + }, +}; diff --git a/styles/chatSidebarBackground.css b/styles/chatSidebarBackground.css new file mode 100644 index 0000000..ebd144f --- /dev/null +++ b/styles/chatSidebarBackground.css @@ -0,0 +1,6 @@ +.oft-chatSidebarBackground { + .chat-sidebar:not(.sidebar-popout) { + background: var(--sidebar-background, var(--color-cool-5-90)); + pointer-events: all; /* prevent click-throughs */ + } +} diff --git a/styles/main.css b/styles/main.css index e69de29..079b84a 100644 --- a/styles/main.css +++ b/styles/main.css @@ -0,0 +1,4 @@ +@import url("./chatSidebarBackground.css"); + +/* Make the chat sidebar the same width as all the other tabs */ +.chat-sidebar:not(.sidebar-popout) { width: unset; }