mirror of
https://github.com/zsviczian/obsidian-excalidraw-plugin.git
synced 2025-08-06 05:46:28 +00:00
durability
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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<HeatmapProps> {
|
||||
render() {
|
||||
const element = document.getElementById("color-elem");
|
||||
@@ -27,6 +43,10 @@ class Heatmap extends React.Component<HeatmapProps> {
|
||||
elem.style.fill = base;
|
||||
elem.style.opacity = "0.92";
|
||||
}
|
||||
for (let elem of Array.from(document.getElementsByClassName("color5") as HTMLCollectionOf<HTMLElement>)) {
|
||||
elem.style.fill = base;
|
||||
elem.style.opacity = "1";
|
||||
}
|
||||
}
|
||||
return <div style={{ padding: "10px 0px 0px 10px", maxWidth: "300px", marginLeft: "auto", marginRight: "auto", fontSize: "4px !important" }} id="calendar-container">
|
||||
<ReactCalendarHeatmap
|
||||
@@ -41,7 +61,7 @@ class Heatmap extends React.Component<HeatmapProps> {
|
||||
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()}
|
||||
/>
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user