From 3fc78ad1bd52bc6ff69297ec9ecca3e6fed1736c Mon Sep 17 00:00:00 2001 From: Michael Lee Date: Wed, 29 Jun 2022 23:48:27 -0400 Subject: [PATCH] Allowed the title to be dimmed --- main.ts | 35 +++++++++++++++++++++++++++++++++-- manifest.json | 20 ++++++++++---------- package.json | 2 +- styles.css | 8 ++++++++ versions.json | 15 ++++++++------- 5 files changed, 60 insertions(+), 20 deletions(-) diff --git a/main.ts b/main.ts index d4cca15..de7ee9b 100644 --- a/main.ts +++ b/main.ts @@ -3,12 +3,14 @@ import { App, Plugin, addIcon, PluginSettingTab, Setting } from 'obsidian'; interface StillePluginSettings { unfocusedLevel: number; statusBarLabel: boolean; + unfocusTitle: boolean; } // Default settings values const DEFAULT_SETTINGS: StillePluginSettings = { unfocusedLevel: 0.3, - statusBarLabel: true + statusBarLabel: true, + unfocusTitle: false } // Icon for the side dock ribbon toggle for Stille @@ -35,6 +37,8 @@ export default class StillePlugin extends Plugin { this.statusBar = this.addStatusBarItem(); this.statusBar.setText('Stille on'); this.toggleLabelDisplay(this.settings.statusBarLabel); + + this.toggleDimTitle(this.settings.unfocusTitle); // Add Stille toggle shortcut this.addCommand({ @@ -93,8 +97,9 @@ export default class StillePlugin extends Plugin { removeStyleFromView() { if (this.styleElement) { this.styleElement.remove(); - this.styleElement = null; document.body.removeClass('StilleStyle'); + document.body.removeClass('StilleHideStatus'); + document.body.removeClass('StilleUnfocusTitle'); } } @@ -111,12 +116,26 @@ export default class StillePlugin extends Plugin { document.body.classList.add('StilleHideStatus'); } } + + toggleDimTitle(value:boolean) { + if (value) { + document.body.classList.add('StilleUnfocusTitle'); + } else { + document.body.classList.remove('StilleUnfocusTitle'); + } + } async toggleLabel(value:boolean) { this.toggleLabelDisplay(value); this.settings.statusBarLabel = value; await this.saveSettings(); } + + async toggleTitle(value:boolean) { + this.toggleDimTitle(value); + this.settings.unfocusTitle = value; + await this.saveSettings(); + } refresh() { this.removeStyleFromView(); @@ -168,5 +187,17 @@ class StilleSettingTab extends PluginSettingTab { await this.plugin.toggleLabel(!this.plugin.settings.statusBarLabel); }) ) + + // Adds settings option to toggle title to be dimmed + // This provides a toggle which controls the settings value for the statusBarLabel + new Setting(containerEl) + .setName('Dim title') + .setDesc('Dim the title of the note when Stille is on.') + .addToggle(title => title + .setValue(this.plugin.settings.unfocusTitle) + .onChange(async () => { + await this.plugin.toggleTitle(!this.plugin.settings.unfocusTitle); + }) + ) } } diff --git a/manifest.json b/manifest.json index 9538e48..bada049 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ -{ - "id": "obsidian-stille", - "name": "Stille", - "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", - "isDesktopOnly": false -} +{ + "id": "obsidian-stille", + "name": "Stille", + "version": "1.2.0", + "minAppVersion": "0.13.0", + "description": "Focus on your writing, a section at a time.", + "author": "Michael Lee", + "authorUrl": "https://michaelsoolee.com", + "isDesktopOnly": false +} \ No newline at end of file diff --git a/package.json b/package.json index a8db948..d7b87de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-stille", - "version": "1.1.0", + "version": "1.2.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 96b20a7..2a97986 100644 --- a/styles.css +++ b/styles.css @@ -19,3 +19,11 @@ body.StilleStyle.is-mobile .cm-editor .cm-active { body.StilleHideStatus .status-bar-item.plugin-obsidian-stille { display: none; } + +body.StilleUnfocusTitle .view-header-title { + opacity: var(--unfocusedLevel); +} + +body.StilleUnfocusTitle .view-header-title:focus-within { + opacity: 1.0; +} \ No newline at end of file diff --git a/versions.json b/versions.json index e8c00a5..104f43f 100644 --- a/versions.json +++ b/versions.json @@ -1,7 +1,8 @@ -{ - "1.1.0": "0.13.0", - "1.0.3": "0.9.12", - "1.0.2": "0.9.12", - "1.0.1": "0.9.12", - "1.0.0": "0.9.12" -} +{ + "1.0.0": "0.9.12", + "1.0.1": "0.9.12", + "1.0.2": "0.9.12", + "1.0.3": "0.9.12", + "1.1.0": "0.13.0", + "1.2.0": "0.13.0" +} \ No newline at end of file