ratatui-org / ratatui

Rust library that's all about cooking up terminal user interfaces (TUIs) 👨‍🍳🐀
https://ratatui.rs
MIT License
8.96k stars 274 forks source link

docs(examples): simplify the barchart example #1079

Open joshka opened 2 months ago

joshka commented 2 months ago
joshka commented 2 months ago

I made a bunch of changes:

joshka commented 2 months ago

The idea behind this is to do similar changes to all the examples, and to make them take this form.

joshka commented 2 months ago

fix: tweaks

EdJoPaTo commented 2 months ago

Given that there are other Repos with widget examples… how about a ratatui feature for an example base? Other widgets in other repos can also use them as a common base to demonstrate their widgets then.

joshka commented 2 months ago

Given that there are other Repos with widget examples… how about a ratatui feature for an example base? Other widgets in other repos can also use them as a common base to demonstrate their widgets then.

An example is just an app. Adding code to make writing examples easy is adding code to make writing apps easy. There shouldn't be an "example base", there should be functions that make using common parts of ratatui easy. Those changes are more difficult than cleaning up existing code to make it easier for new users to understand.

EdJoPaTo commented 2 months ago

Given that there are other Repos with widget examples… how about a ratatui feature for an example base? Other widgets in other repos can also use them as a common base to demonstrate their widgets then.

An example is just an app. Adding code to make writing examples easy is adding code to make writing apps easy. There shouldn't be an "example base", there should be functions that make using common parts of ratatui easy. Those changes are more difficult than cleaning up existing code to make it easier for new users to understand.

This creates a common example base. My point is to make this common.rs reusable for other repos too, not just examples within the ratatui repo. That way they can also be more consistent.

joshka commented 2 months ago

I think it might be better to incorporate that file in each example instead as it makes each example self contained as a single file.

Publishing public code locks you into supporting it and not making changes that would break code that uses it. I'd prefer this code to be copied instead of referenced.