Skip to content

Commit

Permalink
Added label setting toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
michaellee committed Feb 25, 2022
1 parent 3c61645 commit fb7e161
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 5 deletions.
32 changes: 30 additions & 2 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M195 125c0-26.3 5.3-51.3 14.9-74.1C118.7 73 51 155.1 51 253c0 114.8 93.2 208 208 208 97.9 0 180-67.7 202.1-158.9-22.8 9.6-47.9 14.9-74.1 14.9-106 0-192-86-192-192z"/></svg>`
Expand All @@ -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',
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
})
)
}
}
4 changes: 2 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
1 change: 1 addition & 0 deletions versions.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit fb7e161

Please sign in to comment.