docs(examples): move colors-rgb example to examples folder (#1582)

- **docs: move colors-rgb example to examples folder**
- **docs: update main examples README**

---------

Co-authored-by: Orhun Parmaksız <orhunparmaksiz@gmail.com>
This commit is contained in:
Josh McKinney 2025-02-04 10:40:10 -08:00 committed by GitHub
parent 0b24e6c7bf
commit 867c4bc4e9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 66 additions and 36 deletions

9
Cargo.lock generated
View File

@ -559,6 +559,15 @@ version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "colors-rgb"
version = "0.1.0"
dependencies = [
"color-eyre",
"palette",
"ratatui",
]
[[package]]
name = "compact_str"
version = "0.8.1"

View File

@ -49,18 +49,30 @@ This is the demo example from the main README and crate page. [Source](./apps/de
![Demo2](https://github.com/ratatui/ratatui/blob/images/examples/demo2.gif?raw=true)
## Mouse Drawing demo
Shows how to handle mouse events. [Source](./apps/mouse-drawing/).
## Async GitHub demo
Shows how to fetch data from GitHub API asynchronously. [Source](./apps/async-github/).
## Weather demo
Shows how to render weather data using barchart widget. [Source](./apps/weather/).
## Calendar explorer demo
Shows how to render a calendar with different styles. [Source](./apps/calendar-explorer/).
## Canvas demo
Shows how to render a canvas with different shapes. [Source](./apps/canvas/).
## Colors-RGB demo
This example shows the full range of RGB colors in an animation. [Source](./apps/colors-rgb/).
## Input form
Shows how to render a form with input fields. [Source](./apps/input-form/).
## Mouse Drawing demo
Shows how to handle mouse events. [Source](./apps/mouse-drawing/).
## Weather demo
Shows how to render weather data using barchart widget. [Source](./apps/weather/).

View File

@ -0,0 +1,15 @@
[package]
name = "colors-rgb"
version = "0.1.0"
publish = false
license.workspace = true
edition.workspace = true
rust-version.workspace = true
[dependencies]
color-eyre.workspace = true
palette = "0.7.6"
ratatui.workspace = true
[lints]
workspace = true

View File

@ -0,0 +1,9 @@
# Colors-RGB demo
This example shows the full range of RGB colors in an animation.
To run this demo:
```shell
cargo run -p colors-rgb
```

View File

@ -1,30 +1,20 @@
//! # [Ratatui] `Colors_RGB` example
//! A Ratatui example that shows the full range of RGB colors that can be displayed in the terminal.
//!
//! The latest version of this example is available in the [examples] folder in the repository.
//! Requires a terminal that supports 24-bit color (true color) and unicode.
//!
//! 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.
//! This example also demonstrates how implementing the Widget trait on a mutable reference
//! allows the widget to update its state while it is being rendered. This allows the fps
//! widget to update the fps calculation and the colors widget to update a cached version of
//! the colors to render instead of recalculating them every frame.
//!
//! See the [examples readme] for more information on finding examples that match the version of the
//! library you are using.
//! This is an alternative to using the `StatefulWidget` trait and a separate state struct. It
//! is useful when the state is only used by the widget and doesn't need to be shared with
//! other widgets.
//!
//! [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
// This example shows the full range of RGB colors that can be displayed in the terminal.
//
// Requires a terminal that supports 24-bit color (true color) and unicode.
//
// This example also demonstrates how implementing the Widget trait on a mutable reference
// allows the widget to update its state while it is being rendered. This allows the fps
// widget to update the fps calculation and the colors widget to update a cached version of
// the colors to render instead of recalculating them every frame.
//
// This is an alternative to using the `StatefulWidget` trait and a separate state struct. It
// is useful when the state is only used by the widget and doesn't need to be shared with
// other widgets.
//! 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};

View File

@ -142,11 +142,6 @@ bench = false
name = "main"
harness = false
[[example]]
name = "colors_rgb"
required-features = ["crossterm", "palette"]
doc-scrape-examples = true
[[example]]
name = "constraint-explorer"
required-features = ["crossterm"]