From fb7e161e63b1d5802c615447ac11ef0c4a02a47b Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Thu, 24 Feb 2022 21:57:59 -0500 Subject: [PATCH] Added label setting toggle --- main.ts | 32 ++++++++++++++++++++++++++++++-- manifest.json | 4 ++-- package.json | 2 +- styles.css | 4 ++++ versions.json | 1 + 5 files changed, 38 insertions(+), 5 deletions(-) diff --git a/main.ts b/main.ts index 979f940..2c1b94f 100644 --- a/main.ts +++ b/main.ts @@ -2,10 +2,12 @@ import { App, Modal, Notice, Plugin, addIcon, PluginSettingTab, Setting } from ' interface StillePluginSettings { unfocusedLevel: number; + statusBarLabel: boolean; } const DEFAULT_SETTINGS: StillePluginSettings = { - unfocusedLevel: 0.3 + unfocusedLevel: 0.3, + statusBarLabel: true } const moonIcon = `` @@ -27,7 +29,9 @@ export default class StillePlugin extends Plugin { this.statusBar = this.addStatusBarItem(); this.statusBar.setText('Stille on'); - + + this.toggleLabelDisplay(this.settings.statusBarLabel); + this.addCommand({ id: 'toggleStille', name: 'Toggle Stille', @@ -93,6 +97,20 @@ export default class StillePlugin extends Plugin { }`; } + toggleLabelDisplay(value:boolean) { + if (value) { + document.body.classList.remove('StilleHideStatus'); + } else { + document.body.classList.add('StilleHideStatus'); + } + } + + async toggleLabel(value:boolean) { + this.toggleLabelDisplay(value); + this.settings.statusBarLabel = value; + await this.saveSettings(); + } + refresh() { this.removeStyleFromView(); this.addStyleToView(); @@ -130,5 +148,15 @@ class StilleSettingTab extends PluginSettingTab { await this.plugin.saveSettings(); this.plugin.refresh(); })); + + new Setting(containerEl) + .setName('Toggle status bar label') + .setDesc('Use this to toggle the visibility of the status bar label for Stille.') + .addToggle(barStatus => barStatus + .setValue(this.plugin.settings.statusBarLabel) + .onChange(async () => { + await this.plugin.toggleLabel(!this.plugin.settings.statusBarLabel); + }) + ) } } diff --git a/manifest.json b/manifest.json index 6db42cc..9538e48 100644 --- a/manifest.json +++ b/manifest.json @@ -1,8 +1,8 @@ { "id": "obsidian-stille", "name": "Stille", - "version": "1.0.3", - "minAppVersion": "0.9.12", + "version": "1.1.0", + "minAppVersion": "0.13.0", "description": "Focus on your writing, a section at a time.", "author": "Michael Lee", "authorUrl": "https://michaelsoolee.com", diff --git a/package.json b/package.json index 592687c..4202f75 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-stille", - "version": "1.0.3", + "version": "1.1.0", "description": "An Obsidian plugin that helps you focus on your writing, a section at a time.", "main": "main.js", "scripts": { diff --git a/styles.css b/styles.css index aeb5b6d..96b20a7 100644 --- a/styles.css +++ b/styles.css @@ -15,3 +15,7 @@ body.StilleStyle .cm-editor .cm-active { body.StilleStyle.is-mobile .cm-editor .cm-active { opacity: 1.0; } + +body.StilleHideStatus .status-bar-item.plugin-obsidian-stille { + display: none; +} diff --git a/versions.json b/versions.json index 5397674..e8c00a5 100644 --- a/versions.json +++ b/versions.json @@ -1,4 +1,5 @@ { + "1.1.0": "0.13.0", "1.0.3": "0.9.12", "1.0.2": "0.9.12", "1.0.1": "0.9.12",