diff --git a/manifest.json b/manifest.json index a2f7fa4..e6f4f7b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-daily-stats", "name": "Daily Stats", - "version": "1.0.3", + "version": "1.0.4", "minAppVersion": "0.10.12", "description": "Track your daily word count across all notes in your vault.", "author": "Dhruvik Parikh", diff --git a/package.json b/package.json index 3e0922e..223a84e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-daily-stats", - "version": "1.0.3", + "version": "1.0.4", "description": "This is an Obsidian.md plugin that lets you view your daily word count.", "main": "main.js", "scripts": { diff --git a/src/calendar.tsx b/src/calendar.tsx index a194ca4..2d95a64 100644 --- a/src/calendar.tsx +++ b/src/calendar.tsx @@ -6,6 +6,22 @@ interface HeatmapProps { data: any[]; } +const getColorLevel = (count: number) => { + if (count < 150) { + return 1; + } + if (count < 400) { + return 2; + } + if (count < 750) { + return 3; + } + if (count < 1500) { + return 4; + } + return 5; +} + class Heatmap extends React.Component { render() { const element = document.getElementById("color-elem"); @@ -27,6 +43,10 @@ class Heatmap extends React.Component { elem.style.fill = base; elem.style.opacity = "0.92"; } + for (let elem of Array.from(document.getElementsByClassName("color5") as HTMLCollectionOf)) { + elem.style.fill = base; + elem.style.opacity = "1"; + } } return
{ if (!value || value.count == 0) { return 'color-empty'; } - return `color${Math.min(MAX_COLORS, Math.floor(Math.log(value.count) / Math.log(COLOR_FREQ)))}`; + return `color${getColorLevel(value.count)}`; }} titleForValue={(value) => !value || value.date === null ? '' : value.count + ' words on ' + new Date(value.date).toLocaleDateString()} /> diff --git a/src/main.ts b/src/main.ts index 5aeae1d..c304673 100644 --- a/src/main.ts +++ b/src/main.ts @@ -59,10 +59,6 @@ export default class DailyStats extends Plugin { }, }); - this.registerEvent( - this.app.workspace.on("quit", this.onunload.bind(this)) - ); - this.registerEvent( this.app.workspace.on("quick-preview", this.onQuickPreview.bind(this)) ); @@ -97,10 +93,6 @@ export default class DailyStats extends Plugin { }); } - async onunload() { - await this.saveSettings(); - } - onQuickPreview(file: TFile, contents: string) { if (this.app.workspace.getActiveViewOfType(MarkdownView)) { this.debouncedUpdate(contents, file.path);