From 4314a3a70ab24872323b34415a8b62058dc5aef8 Mon Sep 17 00:00:00 2001 From: Ryo Hilmawan <54142180+CloudHill@users.noreply.github.com> Date: Fri, 6 Nov 2020 03:08:47 +0700 Subject: [PATCH] Added options to mod.js Added the option to individually select which buttons (share, updates, favorite) to replace with icons --- mods/topbar-icons/mod.js | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) diff --git a/mods/topbar-icons/mod.js b/mods/topbar-icons/mod.js index 63bdd10..237129d 100644 --- a/mods/topbar-icons/mod.js +++ b/mods/topbar-icons/mod.js @@ -16,12 +16,36 @@ module.exports = { tags: ['extension'], name: 'topbar icons', desc: - 'replaces the topbar buttons (share, updates, favorite) with icons.', + 'replaces the topbar buttons with icons.', + options: [ + { + key: 'share', + label: 'share', + type: 'toggle', + value: true, + }, + { + key: 'updates', + label: 'updates', + type: 'toggle', + value: true, + }, + { + key: 'favorite', + label: 'favorite', + type: 'toggle', + value: true, + }, + ], version: '1.0.0', author: 'CloudHill', hacks: { 'renderer/preload.js'(store, __exports) { const icons = { + selected: [ + ...(store().updates ? ['updates'] : []), + ...(store().favorite ? ['favorite'] : []), + ], share: fs.readFile(path.resolve(`${__dirname}/icons/share.svg`)), updates: { on: fs.readFile(path.resolve(`${__dirname}/icons/updates_on.svg`)), @@ -73,12 +97,16 @@ module.exports = { async function setIcons(buttons) { const buttonList = buttons.children; - buttonList[0].innerHTML = await icons.share; + if (store().share) { + buttonList[0].classList.add('notion-topbar-icon'); + buttonList[0].innerHTML = await icons.share; + } const elements = { updates: buttonList[1], favorite: buttonList[2], }; - for (let btn of ['updates', 'favorite']) { + for (let btn of icons.selected) { + elements[btn].classList.add('notion-topbar-icon') elements[btn].prepend( createElement( `