-
-
Notifications
You must be signed in to change notification settings - Fork 352
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(calendar): add calendar widget #138
Conversation
b6dde51
to
916a0ba
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Some minor comments only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes for header LGTM.
I'm not sure whether the time
dependency will be an actual problem for anyone (I'd guess it's probably a fundamental enough crate that probably not). The bigger issue on that idea though is that if you do plan to move to using chrono down the line, perhaps feature flagging on whether to use time or chrono calendars could be worth doing up front. I don't have any strong leanings either way on this. It could be best to just leave this until it's an issue.
I'd lean towards adding the change to calendars::Month
in this PR the name just seems more correct and changing the widget names down the line would break more dependents.
Slapping an approve as no big deal if you don't make that change either.
I fixed up the docs to remove the mention of Chrono. That was leftover from when I was building this for a personal project, and I chose to not migrate to chrono there. We can decide how to add support for it if there's a desire for it from users. About naming, i did the namespaced thing, but went with |
Should we put calendar and other similar new-dependency-introducing widgets behind feature flags? @orhun @mindoodoo |
Hmm, what would you name the feature ? |
|
I put in the machinery for the feature and named it ed: The construct |
I didn't understand why you went with |
Apparently it isn't :). I'm still learning about some of these Cargo directives and I think I misunderstood some of what I read. Pushed a fixup |
Just tested and it works well. GJ! 🎉 One question though, is it possible to add tests for this? |
I can add tests (i think). I'll see what I can get in place over the weekend. |
Add `widget-calendar` feature. Dispalys a calendar for the month provided in the constructor with per-day styling options, and several display options. This puts `widgets::calendar` behind the `widget-calendar` feature and makes the `time` dependency optional unless the feature is enabled.
cfaed1e
to
4e4852d
Compare
I've added some tests for the widget, as well as for the date styler. One thing to note, I'm not sure if CI will actually run the tests, because I don't know if it builds with default features or does something "smart". I added a feature edit - the output of the test runners in CI shows that the calendar tests were not run. I'm not sure how to change what features are enabled for the runner. |
I think you can update diff --git a/Makefile.toml b/Makefile.toml
index 8afba0a..db9354f 100644
--- a/Makefile.toml
+++ b/Makefile.toml
@@ -100,11 +100,11 @@ args = [
]
[tasks.test-crossterm]
-env = { TUI_FEATURES = "serde,crossterm" }
+env = { TUI_FEATURES = "serde,crossterm,all-widgets" }
run_task = "test"
[tasks.test-termion]
-env = { TUI_FEATURES = "serde,termion" }
+env = { TUI_FEATURES = "serde,termion,all-widgets" }
run_task = "test"
[tasks.test] |
4e4852d
to
382ac7b
Compare
382ac7b
to
bf745f4
Compare
Thanks @orhun - that looks like it did the trick, I can see the calendar tests being run now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks awesome man !
A calendar widget that with some display options and styling for individual dates.
This widget displays the month provided to it in the constructor. (see docs and the example for more info).
One thing to note: This pulls in a new dependency, the time crate. Since this adds a dependency, it might be worth putting the widget behind a feature flag - I'm happy to do so if that's desired.