Skip to content
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

docs(examples): add widget implementation example #1147

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

joshka
Copy link
Member

@joshka joshka commented May 25, 2024

This new example documents the various ways to implement widgets in
Ratatui. It demonstrates how to implement the Widget trait on a type,
a reference, and a mutable reference. It also shows how to use the
WidgetRef trait to render boxed widgets.

This new example documents the various ways to implement widgets in
Ratatui. It demonstrates how to implement the `Widget` trait on a type,
a reference, and a mutable reference. It also shows how to use the
`WidgetRef` trait to render boxed widgets.
Copy link
Member

@EdJoPaTo EdJoPaTo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quickly scrolled over it. Still against color_eyre. Also, not sure whether an example using an unstable feature is a great idea…

examples/widget_impl.rs Outdated Show resolved Hide resolved
examples/widget_impl.rs Show resolved Hide resolved
examples/widget_impl.rs Show resolved Hide resolved
examples/widget_impl.rs Outdated Show resolved Hide resolved
@joshka
Copy link
Member Author

joshka commented Jun 4, 2024

I've heard and understood your concern about color_eyre.

The examples are intentionally structured in a way that helps address common scenarios that people run into in real world building Ratatui apps. I've seen evidence (from reading a significant amount of user application code on GitHub and discord) that users often grab code from the example that most matches their particular need rather than looking at all the relevant examples. Having the necessary error handling in every example helps ensure that regardless of where they grab their code from, they're getting a reasonable basis for building their app.

This is not something I'm willing to be convinced otherwise on as the benefit to the Ratatui ecosystem is much larger than the added complexity. The only thing that would make me rethink this is if there was code that was part of Ratatui that basically did the same things. Regardless, that concern is orthogonal, and until we have something that works for that, the right approach is to harmonize the various examples with boilerplate that's easily replaced by calls to that eventual support module.

@kdheepak
Copy link
Collaborator

kdheepak commented Jun 4, 2024

I agree about using color_eyre (or anyhow) for examples, it's something I suspect a lot of users appreciate (I know I do) and easy to remove for those that know how to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants