|
1 |
+ |
# alloy_tui
|
|
2 |
+ |
|
|
3 |
+ |
Alloy's design system for [ratatui](https://ratatui.rs): themed widgets, a
|
|
4 |
+ |
reserved keymap, and a focus ring, driven by
|
|
5 |
+ |
[makeover](https://crates.io/crates/makeover) themes.
|
|
6 |
+ |
|
|
7 |
+ |
Extracted from the Alloy console so other terminal UIs can share one look
|
|
8 |
+ |
rather than each re-deriving colors from a palette.
|
|
9 |
+ |
|
|
10 |
+ |
## What it gives you
|
|
11 |
+ |
|
|
12 |
+ |
- **`Theme`** — a makeover `.toml` theme resolved into ratatui `Color`/`Style`.
|
|
13 |
+ |
Two Alloy-specific tokens (`border-subtle`, `border-strong`) are derived
|
|
14 |
+ |
locally so theme files stay minimal and cross-app compatible.
|
|
15 |
+ |
- **Widgets** — `AlloyBlock`, `AlloyList`, `AlloyTabs`, `AlloyStatusBar`,
|
|
16 |
+ |
`AlloyModal`, `AlloyLog`, each taking a `&Theme`.
|
|
17 |
+ |
- **`keys`** — the reserved keymap every Alloy TUI agrees on, so the same keys
|
|
18 |
+ |
mean the same thing across tools.
|
|
19 |
+ |
- **`focus`** — a focus ring, the piece ratatui deliberately leaves to the app.
|
|
20 |
+ |
|
|
21 |
+ |
## Color is information
|
|
22 |
+ |
|
|
23 |
+ |
Chrome is tinted greyscale. Accent color lives on text, carried by `Severity`,
|
|
24 |
+ |
so a colored thing on screen means something rather than decorating. Widgets
|
|
25 |
+ |
enforce this; you get it by using them.
|
|
26 |
+ |
|
|
27 |
+ |
## Usage
|
|
28 |
+ |
|
|
29 |
+ |
```rust
|
|
30 |
+ |
use alloy_tui::{AlloyStatusBar, Theme, hint};
|
|
31 |
+ |
|
|
32 |
+ |
// Resolve a makeover theme into ratatui colors.
|
|
33 |
+ |
let dirs = vec![(makeover::bundled_themes_dir().unwrap(), false)];
|
|
34 |
+ |
let colors = makeover::load_theme(&dirs, "akari-night").unwrap();
|
|
35 |
+ |
let theme = Theme::from_theme(&colors).unwrap();
|
|
36 |
+ |
|
|
37 |
+ |
// Widgets take &Theme.
|
|
38 |
+ |
let footer = AlloyStatusBar::new(&theme, [hint("Tab", "focus"), hint("q", "quit")]);
|
|
39 |
+ |
```
|
|
40 |
+ |
|
|
41 |
+ |
There is deliberately no built-in fallback palette. A missing or malformed
|
|
42 |
+ |
theme is an error you surface, not something papered over by rendering in
|
|
43 |
+ |
colors that exist nowhere in the theme files.
|
|
44 |
+ |
|
|
45 |
+ |
## License
|
|
46 |
+ |
|
|
47 |
+ |
MIT.
|
|
48 |
+ |
|
|
49 |
+ |
The rest of the [Alloy](https://git.sr.ht/~maxmj/alloy) repository is
|
|
50 |
+ |
GPLv3-or-later. This crate is permissive on purpose: it is the reusable design
|
|
51 |
+ |
system, not the application.
|