From 7c40c0bbddca0276523ac717d9df3d2b49594bb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Thu, 6 Feb 2025 23:38:07 +0300 Subject: [PATCH] docs(examples): move popup example to examples folder (#1656) see #1512 --- Cargo.lock | 9 ++++++++ examples/README.md | 4 ++++ examples/apps/popup/Cargo.toml | 14 +++++++++++ examples/apps/popup/README.md | 9 ++++++++ .../apps/popup/src/main.rs | 23 ++++++------------- ratatui/Cargo.toml | 5 ---- 6 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 examples/apps/popup/Cargo.toml create mode 100644 examples/apps/popup/README.md rename ratatui/examples/popup.rs => examples/apps/popup/src/main.rs (77%) diff --git a/Cargo.lock b/Cargo.lock index 79ee5056..cd3f2d93 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2294,6 +2294,15 @@ dependencies = [ "plotters-backend", ] +[[package]] +name = "popup" +version = "0.0.0" +dependencies = [ + "color-eyre", + "crossterm", + "ratatui", +] + [[package]] name = "powerfmt" version = "0.2.0" diff --git a/examples/README.md b/examples/README.md index 28809856..b580a496 100644 --- a/examples/README.md +++ b/examples/README.md @@ -114,6 +114,10 @@ Shows how to handle mouse events. [Source](./apps/mouse-drawing/). Shows how to create a minimal application. [Source](./apps/minimal/). +## Popup demo + +Shows how to handle popups. [Source](./apps/popup/). + ## Weather demo Shows how to render weather data using barchart widget. [Source](./apps/weather/). diff --git a/examples/apps/popup/Cargo.toml b/examples/apps/popup/Cargo.toml new file mode 100644 index 00000000..0b3b339d --- /dev/null +++ b/examples/apps/popup/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "popup" +publish = false +license.workspace = true +edition.workspace = true +rust-version.workspace = true + +[dependencies] +color-eyre.workspace = true +crossterm.workspace = true +ratatui.workspace = true + +[lints] +workspace = true diff --git a/examples/apps/popup/README.md b/examples/apps/popup/README.md new file mode 100644 index 00000000..c93d6646 --- /dev/null +++ b/examples/apps/popup/README.md @@ -0,0 +1,9 @@ +# Popup demo + +This example shows how to render line, bar, and scatter charts. + +To run this demo: + +```shell +cargo run -p popup +``` diff --git a/ratatui/examples/popup.rs b/examples/apps/popup/src/main.rs similarity index 77% rename from ratatui/examples/popup.rs rename to examples/apps/popup/src/main.rs index 2289154d..1dc46266 100644 --- a/ratatui/examples/popup.rs +++ b/examples/apps/popup/src/main.rs @@ -1,21 +1,12 @@ -//! # [Ratatui] Popup example -//! -//! The latest version of this example is available in the [examples] folder in the repository. -//! -//! Please note that the examples are designed to be run against the `main` branch of the Github -//! repository. This means that you may not be able to compile with the latest release version on -//! crates.io, or the one that you have installed locally. -//! -//! See the [examples readme] for more information on finding examples that match the version of the -//! library you are using. -//! -//! [Ratatui]: https://github.com/ratatui/ratatui -//! [examples]: https://github.com/ratatui/ratatui/blob/main/examples -//! [examples readme]: https://github.com/ratatui/ratatui/blob/main/examples/README.md - +/// A Ratatui example that demonstrates how to handle popups. // See also https://github.com/joshka/tui-popup and // https://github.com/sephiroth74/tui-confirm-dialog - +/// +/// This example runs with the Ratatui library code in the branch that you are currently +/// reading. See the [`latest`] branch for the code which works with the most recent Ratatui +/// release. +/// +/// [`latest`]: https://github.com/ratatui/ratatui/tree/latest use color_eyre::Result; use ratatui::{ crossterm::event::{self, Event, KeyCode, KeyEventKind}, diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index 96394fe4..869b5af5 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -158,11 +158,6 @@ name = "panic" required-features = ["crossterm"] doc-scrape-examples = true -[[example]] -name = "popup" -required-features = ["crossterm"] -doc-scrape-examples = true - [[example]] name = "scrollbar-widget" required-features = ["crossterm"]