Skip to content

Commit

Permalink
feat(showcase): showcase paragraph widget (#387)
Browse files Browse the repository at this point in the history
  • Loading branch information
bulkan authored Jan 23, 2024
1 parent 3a08036 commit 7441bd8
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 1 deletion.
9 changes: 9 additions & 0 deletions code/widget-showcase/paragraph.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# A VHS tape. See https://github.com/charmbracelet/vhs
Output "../../src/content/docs/showcase/widgets/paragraph.gif"
Set Theme "Aardvark Blue"
Set Width 800
Set Height 220
Type "cargo run -- -w paragraph" Enter
Sleep 5s
Screenshot "../../src/content/docs/showcase/widgets/paragraph.png"
Sleep 1s
1 change: 1 addition & 0 deletions code/widget-showcase/src/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ pub mod chart;
pub mod gauge;
pub mod line_gauge;
pub mod list;
pub mod paragraph;
pub mod table;
16 changes: 16 additions & 0 deletions code/widget-showcase/src/examples/paragraph.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use ratatui::{prelude::*, widgets::*};

pub fn render(frame: &mut Frame) {
let text = vec![
Line::from("Hello, Ratatui".white().on_blue().italic()),
Line::from("This is a colorful line".red().underlined()),
Line::from("Be bold with your paragraphs".bold()),
];

let paragraph = Paragraph::new(text)
.bold()
.white()
.alignment(Alignment::Center);

frame.render_widget(paragraph, frame.size());
}
2 changes: 2 additions & 0 deletions code/widget-showcase/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ enum Widget {
LineGauge,
List,
Table,
Paragraph,
}

fn main() -> color_eyre::Result<()> {
Expand Down Expand Up @@ -103,6 +104,7 @@ impl App {
Widget::LineGauge => line_gauge::render(frame),
Widget::List => list::render(frame),
Widget::Table => table::render(frame),
Widget::Paragraph => paragraph::render(frame),
}
Ok(())
}
Expand Down
4 changes: 3 additions & 1 deletion src/content/docs/showcase/widgets/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ https://github.com/ratatui-org/website/issues/249 for information about how to c

![List](./list.png)

## Paragraph <LinkBadge href="https://docs.rs/ratatui/latest/ratatui/widgets/struct.Paragraph.html" text="Docs" /> <LinkBadge text="Help Wanted" href="https://github.com/ratatui-org/website/issues/249" variant="caution" />
## Paragraph <LinkBadge href="https://docs.rs/ratatui/latest/ratatui/widgets/struct.Paragraph.html" text="Docs" />

![Paragraph](./paragraph.png)

## Scrollbar <LinkBadge href="https://docs.rs/ratatui/latest/ratatui/widgets/struct.Scrollbar.html" text="Docs" /> <LinkBadge text="Help Wanted" href="https://github.com/ratatui-org/website/issues/249" variant="caution" />

Expand Down
Binary file added src/content/docs/showcase/widgets/paragraph.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/content/docs/showcase/widgets/paragraph.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7441bd8

Please sign in to comment.