Richardsl / heatmap-calendar-obsidian

An Obsidian plugin for displaying data in a calendar similar to the github activity calendar
Apache License 2.0
614 stars 102 forks source link

Add ability to define global color schemes via the Settings panel #74

Closed sunyatasattva closed 1 year ago

sunyatasattva commented 1 year ago

This PR adds the ability for the users to add their custom color schemes via the Settings panel. These color schemes are available globally and can be referenced by their user-defined key.

The UI could definitely use some improvement, but for now I think it's better than nothing and can be iterated upon.

Screenshot 2023-02-25 at 23 31 35

The users can add custom color schemes by adding a key and a valid array. They can also delete their custom schemes, but not the default one. Inputs are validated for these rules:

  1. Must have a name
  2. Must provide a valid color array

Documentation is included.

Testing instructions

Positive case

  1. Open Obsidian Settings > Heatmap Calendar
  2. Make sure the default color scheme is available there and can't be deleted.
  3. Input a color scheme name.
  4. Input a color array.
  5. Click the plus button.
  6. Make sure the new color scheme appears in the UI.
  7. Try using the color scheme in your data as mentioned in the docs.

Negative case

  1. Repeat steps 1–2 above.
  2. Click on the plus button.
  3. A validation error should appear on the colors array input.
  4. Try to input invalid JSON or an array of strings which are not valid CSS colors.
  5. A validation error should appear on the colors array input.
  6. Input a valid array.
  7. Click on the plus button.
  8. A validation error should appear on the colors name input.