habit-tracker icon indicating copy to clipboard operation
habit-tracker copied to clipboard

HabitTracker.svelte Component

Open SarcevicAntonio opened this issue 9 months ago • 5 comments

Hello everyone! I've wanted to change a few things and submit a PR and saw that there was a link to a guide on using Svelte for Obsidian plugins and well... I'm in love Svelte, and I had to port the whole thing. I've also added a few features from the TODO and as I've said I also wanted to change a few things.

  • chore: UI was rewritten as a Svelte component

    • thanks to svelte, the ui component now only ~~60%~~ as big, even with all the features below added 🎉
      • I just realized my original calculation was not accurate, since I forgot to include the CSS. The component is only 53% of the characters as the files it replaces (6946 chars v 12999 chars)
    • the CSS is different, because I chose to rewrite it inside the component itself without any verbose css naming conventions (svelte styles are scoped by default). ofc we can adjust the design before merging.
    • I also chose to include date-fns, because it looked like the API would fit the previous date handling well
  • feat: show current day as green and add the option to mark an additional day (e.g. the current journal files day)

    • we can talk about the colors here, and if we event want to make them configurable maybe?
  • feat: add button that allows to add a new habit file

    • i'm not sure on the design on this one, so I made it configurable. either way a button get's displayed for the empty state so the onboarding is dead simple.
  • feat: check for habit updates every 5 seconds (great for obsidian sync)

    • i thought this was a practical solution, but just now i learned there are hooks for some events in obsidian we could use instead like on('changed'), on('create'), on('deleted') and on('rename') we could use to optimize this if we'd like to (while the polling works pretty well, but the code is a bit stinky tbh 😅)
  • feat: add option to hide habits that do not have activity in shown time frame

    • also made this configurable, since otherwise new habits wouldn't show up at all which i thought would be bad ux.
  • I've also taken the liberty to change the readme a bit to simplify the setup process and to explain the new options

This PR is to get feedback and decide what to do with the plugin going forward. Do we want to merge this (or something like it), or should I maintain a fork instead? @zoreet 🤔

SarcevicAntonio avatar May 16 '24 20:05 SarcevicAntonio