From bc983629501c1f9f674800765b1465e77da1cf19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 8 Jul 2024 10:13:06 +0200 Subject: [PATCH 1/2] Add a new setting to define tab width --- main.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/main.ts b/main.ts index f1a2311..2770461 100644 --- a/main.ts +++ b/main.ts @@ -2,10 +2,12 @@ import { App, Plugin, PluginSettingTab, Setting } from 'obsidian'; interface ShrinkPinnedTabsSettings { hideTitle: boolean; + tabWidth: number; } const DEFAULT_SETTINGS: ShrinkPinnedTabsSettings = { hideTitle: false, + tabWidth: 60, } export default class ShrinkPinnedTabs extends Plugin { @@ -81,5 +83,20 @@ class ShrinkPinnedTabsSettingTab extends PluginSettingTab { this.plugin.refresh(); }) ); + + new Setting(containerEl) + .setName('Width tab') + .setDesc('Defines the width tab when shrinked') + .addSlider((text) => + text + .setLimits(0, 160, 10) + .setValue(this.plugin.settings.tabWidth) + .setDynamicTooltip() + .onChange((value) => { + this.plugin.settings.tabWidth = value; + this.plugin.saveData(this.plugin.settings); + this.plugin.refresh(); + }) + ); } } From 02655b819d2db215e371b46507eacade2c8100ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicolas=20L=C5=93uillet?= Date: Mon, 15 Jul 2024 14:27:58 +0200 Subject: [PATCH 2/2] Add css to change tab width --- main.ts | 3 +++ styles.css | 5 ----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/main.ts b/main.ts index 2770461..4234fd0 100644 --- a/main.ts +++ b/main.ts @@ -34,6 +34,7 @@ export default class ShrinkPinnedTabs extends Plugin { onunload() { console.log('Unloading Shrink pinned tabs plugin'); + this.updateStyle() } async loadSettings() { @@ -48,6 +49,7 @@ export default class ShrinkPinnedTabs extends Plugin { // update the styles (at the start, or as the result of a settings change) updateStyle = () => { + console.log('Update style'); const tabs = document.querySelectorAll('.workspace-tab-header:has(.mod-pinned)'); if (tabs != null) { for (var i = 0; i < tabs.length; i++) { @@ -55,6 +57,7 @@ export default class ShrinkPinnedTabs extends Plugin { if (title != null) { title[0].toggleClass('mod-pinned-hide', this.settings.hideTitle); } + tabs[i].style.width = this.settings.tabWidth + 'px'; } } } diff --git a/styles.css b/styles.css index da8e653..e29f34b 100644 --- a/styles.css +++ b/styles.css @@ -1,8 +1,3 @@ -.workspace-tab-header:has(.mod-pinned) { - /* shrink if pinned */ - max-width: 80px !important; -} - /* class to hide tab title */ .mod-pinned-hide { display: none;