From cf97620c7f0217b4b9296a7d06577c74cd5402c5 Mon Sep 17 00:00:00 2001 From: Theodore Dubois Date: Sun, 4 Oct 2020 16:29:36 -0700 Subject: [PATCH] Make the default font size 13 pt to match a recent Twitch change --- src/modules/chat/index.js | 7 ++++--- src/sites/twitch-clips/modules/chat/index.js | 7 ++++--- src/sites/twitch-twilight/modules/chat/index.js | 8 ++++---- src/utilities/constants.js | 4 +++- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/modules/chat/index.js b/src/modules/chat/index.js index 00940c5c..971465bc 100644 --- a/src/modules/chat/index.js +++ b/src/modules/chat/index.js @@ -9,6 +9,7 @@ import dayjs from 'dayjs'; import Module from 'utilities/module'; import {createElement, ManagedStyle} from 'utilities/dom'; import {timeout, has, glob_to_regex, escape_regex, split_chars} from 'utilities/object'; +import {CHAT_FONT_SIZE} from 'utilities/constants'; import Badges from './badges'; import Emotes from './emotes'; @@ -100,7 +101,7 @@ export default class Chat extends Module { }); this.settings.add('chat.font-size', { - default: 12, + default: CHAT_FONT_SIZE, ui: { path: 'Chat > Appearance >> General', title: 'Font Size', @@ -109,7 +110,7 @@ export default class Chat extends Module { process(val) { val = parseInt(val, 10); if ( isNaN(val) || ! isFinite(val) || val <= 0 ) - return 12; + return null; return val; } @@ -1696,4 +1697,4 @@ export default class Chat extends Module { return data; } -} \ No newline at end of file +} diff --git a/src/sites/twitch-clips/modules/chat/index.js b/src/sites/twitch-clips/modules/chat/index.js index fd2549a6..3168b1cd 100644 --- a/src/sites/twitch-clips/modules/chat/index.js +++ b/src/sites/twitch-clips/modules/chat/index.js @@ -7,6 +7,7 @@ import {get} from 'utilities/object'; import {ColorAdjuster} from 'utilities/color'; +import {CHAT_FONT_SIZE} from 'utilities/constants'; import Module from 'utilities/module'; import Line from './line'; @@ -66,7 +67,7 @@ export default class Chat extends Module { updateChatCSS() { const size = this.chat.context.get('chat.font-size'), emote_alignment = this.chat.context.get('chat.lines.emote-alignment'), - lh = Math.round((20/12) * size); + lh = Math.round((20/CHAT_FONT_SIZE) * size); let font = this.chat.context.get('chat.font-family') || 'inherit'; if ( font.indexOf(' ') !== -1 && font.indexOf(',') === -1 && font.indexOf('"') === -1 && font.indexOf("'") === -1 ) @@ -76,7 +77,7 @@ export default class Chat extends Module { this.css_tweaks.setVariable('chat-line-height', `${lh/10}rem`); this.css_tweaks.setVariable('chat-font-family', font); - this.css_tweaks.toggle('chat-font', size !== 12 || font); + this.css_tweaks.toggle('chat-font', size !== CHAT_FONT_SIZE || font); this.css_tweaks.toggle('emote-alignment-padded', emote_alignment === 1); this.css_tweaks.toggle('emote-alignment-baseline', emote_alignment === 2); @@ -188,4 +189,4 @@ export default class Chat extends Module { room.updateBadges(badges); } -} \ No newline at end of file +} diff --git a/src/sites/twitch-twilight/modules/chat/index.js b/src/sites/twitch-twilight/modules/chat/index.js index a2848666..ec7723ad 100644 --- a/src/sites/twitch-twilight/modules/chat/index.js +++ b/src/sites/twitch-twilight/modules/chat/index.js @@ -6,7 +6,7 @@ import {ColorAdjuster} from 'utilities/color'; import {get, has, make_enum, shallow_object_equals, set_equals, deep_equals} from 'utilities/object'; -import {WEBKIT_CSS as WEBKIT} from 'utilities/constants'; +import {WEBKIT_CSS as WEBKIT, CHAT_FONT_SIZE} from 'utilities/constants'; import {FFZEvent} from 'utilities/events'; import Module from 'utilities/module'; @@ -619,7 +619,7 @@ export default class ChatHook extends Module { const width = this.chat.context.get('chat.width'), size = this.chat.context.get('chat.font-size'), emote_alignment = this.chat.context.get('chat.lines.emote-alignment'), - lh = Math.round((20/12) * size); + lh = Math.round((20/CHAT_FONT_SIZE) * size); let font = this.chat.context.get('chat.font-family') || 'inherit'; if ( font.indexOf(' ') !== -1 && font.indexOf(',') === -1 && font.indexOf('"') === -1 && font.indexOf("'") === -1 ) @@ -631,7 +631,7 @@ export default class ChatHook extends Module { this.css_tweaks.setVariable('chat-width', `${width/10}rem`); this.css_tweaks.setVariable('negative-chat-width', `${-width/10}rem`); - this.css_tweaks.toggle('chat-font', size !== 12 || font !== 'inherit'); + this.css_tweaks.toggle('chat-font', size !== CHAT_FONT_SIZE || font !== 'inherit'); this.css_tweaks.toggle('chat-width', this.settings.get('chat.use-width')); this.css_tweaks.toggle('emote-alignment-padded', emote_alignment === 1); @@ -2598,4 +2598,4 @@ export function formatBitsConfig(config) { } return out; -} \ No newline at end of file +} diff --git a/src/utilities/constants.js b/src/utilities/constants.js index 7c1cd4c5..bd667dd4 100644 --- a/src/utilities/constants.js +++ b/src/utilities/constants.js @@ -124,4 +124,6 @@ export const EmoteTypes = make_enum( 'BitsTier', 'Global', 'TwoFactor' -); \ No newline at end of file +); + +export const CHAT_FONT_SIZE = 13;