From 4393fae54c18c148e7c24206350f0b9e235e5d69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Mon, 10 Feb 2025 01:18:06 +0300 Subject: [PATCH] docs(examples): move scrollbar example to examples folder (#1665) --- Cargo.lock | 9 +++++++ examples/README.md | 4 +++ examples/apps/scrollbar/Cargo.toml | 14 ++++++++++ examples/apps/scrollbar/README.md | 9 +++++++ .../apps/scrollbar/src/main.rs | 27 +++++++------------ ratatui/Cargo.toml | 5 ---- 6 files changed, 46 insertions(+), 22 deletions(-) create mode 100644 examples/apps/scrollbar/Cargo.toml create mode 100644 examples/apps/scrollbar/README.md rename ratatui/examples/scrollbar-widget.rs => examples/apps/scrollbar/src/main.rs (90%) diff --git a/Cargo.lock b/Cargo.lock index 6a44bfce..50ea309f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2946,6 +2946,15 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scrollbar" +version = "0.0.0" +dependencies = [ + "color-eyre", + "crossterm", + "ratatui", +] + [[package]] name = "secrecy" version = "0.10.3" diff --git a/examples/README.md b/examples/README.md index db4c1b8f..dc77641b 100644 --- a/examples/README.md +++ b/examples/README.md @@ -118,6 +118,10 @@ Shows how to handle mouse events. [Source](./apps/mouse-drawing/). Shows how to create a minimal application. [Source](./apps/minimal/). +## Scrollbar demo + +Shows how to render different types of scrollbars. [Source](./apps/scrollbar/). + ## User input demo Shows how to handle user input. [Source](./apps/user-input/). diff --git a/examples/apps/scrollbar/Cargo.toml b/examples/apps/scrollbar/Cargo.toml new file mode 100644 index 00000000..913b5bf7 --- /dev/null +++ b/examples/apps/scrollbar/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "scrollbar" +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/scrollbar/README.md b/examples/apps/scrollbar/README.md new file mode 100644 index 00000000..ba2c8ef0 --- /dev/null +++ b/examples/apps/scrollbar/README.md @@ -0,0 +1,9 @@ +# Scrollbar demo + +This example shows how to render different types of scrollbars. + +To run this demo: + +```shell +cargo run -p scrollbar +``` diff --git a/ratatui/examples/scrollbar-widget.rs b/examples/apps/scrollbar/src/main.rs similarity index 90% rename from ratatui/examples/scrollbar-widget.rs rename to examples/apps/scrollbar/src/main.rs index d6e7bbae..be484cfb 100644 --- a/ratatui/examples/scrollbar-widget.rs +++ b/examples/apps/scrollbar/src/main.rs @@ -1,20 +1,13 @@ -//! # [Ratatui] Scrollbar 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 - -#![warn(clippy::pedantic)] - +/// A Ratatui example that demonstrates how to handle scrollbars. +/// +/// This example demonstrates how to draw various types of vertical and horizontal scrollbars +/// with different styles. +/// +/// 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 std::time::{Duration, Instant}; use color_eyre::Result; diff --git a/ratatui/Cargo.toml b/ratatui/Cargo.toml index ae39f163..3bb397d5 100644 --- a/ratatui/Cargo.toml +++ b/ratatui/Cargo.toml @@ -144,11 +144,6 @@ bench = false name = "main" harness = false -[[example]] -name = "scrollbar-widget" -required-features = ["crossterm"] -doc-scrape-examples = true - [[test]] name = "state_serde" required-features = ["serde"]