Skip to content

Commit

Permalink
feat: add themes dracula, catppuccin, base16 (#19)
Browse files Browse the repository at this point in the history
* feat: add themes dracula, catppuccin, base16
* fix: theme - lint errors
* fix: add example for custom theme
* fix: fix example for doctest
* feat: add example recordings for themes
  • Loading branch information
roele authored Jan 22, 2024
1 parent fc34061 commit 2cf2681
Show file tree
Hide file tree
Showing 14 changed files with 424 additions and 9 deletions.
14 changes: 12 additions & 2 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tasks.assets]
description = "Create assets with vhs"
[tasks."recordings input"]
description = "Create recordings with vhs"
run = """
#!/usr/bin/env bash
# Create VHS recordings of all tape files in the assets directory
Expand All @@ -8,6 +8,16 @@ for i in $(ls -1 assets/*.tape); do
done
"""

[tasks."recordings themes"]
description = "Create theme recordings with vhs"
run = """
#!/usr/bin/env bash
# Create VHS recordings of all tape files in the themes directory
for i in $(ls -1 assets/themes/*.tape); do
vhs $i
done
"""

[tasks.tests]
description = "Run tests"
run = [
Expand Down
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,49 @@ fn main() {
println!("Done!");
}
```

## Themes

Supply your own custom theme or choose from one of the predefined themes:

Derive a custom theme from the default theme.

```rust
let theme = Theme {
selected_prefix: String::from(""),
selected_prefix_fg: Theme::color_rgb(2, 191, 135),
unselected_prefix: String::from(" "),
..Theme::default()
};

Input::new("What's your e-mail?")
.description("Please enter your e-mail address.")
.placeholder("[email protected]")
.theme(theme.clone())
.run()
.expect("error running input")?;
```

### Base 16

![base16](./assets/themes/base16.gif)

### Charm

Default if colors are enabled in the console.

![charm](./assets/themes/charm.gif)

### Catppuccin

![catppuccin](./assets/themes/catppuccin.gif)

### Dracula

![dracula](./assets/themes/dracula.gif)

### New

Default if colors are NOT enabled in the console.

![new](./assets/themes/new.gif)
Binary file added assets/themes/base16.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/themes/base16.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output assets/themes/base16.gif

Set Shell "fish"
Set Padding 10
Set FontSize 16
Set Width 800
Set Height 300
Set TypingSpeed 100ms

Hide
Type "cargo build --example themes && clear" Enter
Sleep 2s
Show

Type "target/debug/examples/themes base16" Enter
Sleep 2s
Type "[email protected]" Sleep 1s Enter

Space Sleep 1s
Down Down Space Sleep 1s
Enter

Sleep 1s
Enter

Sleep 2s
Binary file added assets/themes/catppuccin.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/themes/catppuccin.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output assets/themes/catppuccin.gif

Set Shell "fish"
Set Padding 10
Set FontSize 16
Set Width 800
Set Height 300
Set TypingSpeed 100ms

Hide
Type "cargo build --example themes && clear" Enter
Sleep 2s
Show

Type "target/debug/examples/themes catppuccin" Enter
Sleep 2s
Type "[email protected]" Sleep 1s Enter

Space Sleep 1s
Down Down Space Sleep 1s
Enter

Sleep 1s
Enter

Sleep 2s
Binary file added assets/themes/charm.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/themes/charm.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output assets/themes/charm.gif

Set Shell "fish"
Set Padding 10
Set FontSize 16
Set Width 800
Set Height 300
Set TypingSpeed 100ms

Hide
Type "cargo build --example themes && clear" Enter
Sleep 2s
Show

Type "target/debug/examples/themes charm" Enter
Sleep 2s
Type "[email protected]" Sleep 1s Enter

Space Sleep 1s
Down Down Space Sleep 1s
Enter

Sleep 1s
Enter

Sleep 2s
Binary file added assets/themes/dracula.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/themes/dracula.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output assets/themes/dracula.gif

Set Shell "fish"
Set Padding 10
Set FontSize 16
Set Width 800
Set Height 300
Set TypingSpeed 100ms

Hide
Type "cargo build --example themes && clear" Enter
Sleep 2s
Show

Type "target/debug/examples/themes dracula" Enter
Sleep 2s
Type "[email protected]" Sleep 1s Enter

Space Sleep 1s
Down Down Space Sleep 1s
Enter

Sleep 1s
Enter

Sleep 2s
Binary file added assets/themes/new.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions assets/themes/new.tape
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Output assets/themes/new.gif

Set Shell "fish"
Set Padding 10
Set FontSize 16
Set Width 800
Set Height 300
Set TypingSpeed 100ms

Hide
Type "cargo build --example themes && clear" Enter
Sleep 2s
Show

Type "target/debug/examples/themes" Enter
Sleep 2s
Type "[email protected]" Sleep 1s Enter

Space Sleep 1s
Down Down Space Sleep 1s
Enter

Sleep 1s
Enter

Sleep 2s
45 changes: 45 additions & 0 deletions examples/themes.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
use std::env::args;

use demand::{Confirm, DemandOption, Input, MultiSelect, Theme};

fn main() {
let mut theme = Theme::new();
match args().nth(1) {
Some(arg) => match arg.as_str() {
"base16" => theme = Theme::base16(),
"charm" => theme = Theme::charm(),
"catppuccin" => theme = Theme::catppuccin(),
"dracula" => theme = Theme::dracula(),
_ => {}
},
None => {}
}

let i = Input::new("What's your e-mail?")
.description("Please enter your e-mail address.")
.placeholder("[email protected]")
.theme(theme.clone());
i.run().expect("error running input");

let ms = MultiSelect::new("Interests")
.description("Select your interests")
.min(1)
.max(4)
.filterable(true)
.option(DemandOption::new("Art"))
.option(DemandOption::new("Books"))
.option(DemandOption::new("Food"))
.option(DemandOption::new("Music"))
.option(DemandOption::new("Technology"))
.option(DemandOption::new("Travel"))
.option(DemandOption::new("Sports"))
.theme(theme.clone());
ms.run().expect("error running multi select");

let c = Confirm::new("Confirm privacy policy")
.description("Do you accept the privacy policy?")
.affirmative("Yes")
.negative("No")
.theme(theme.clone());
c.run().expect("error running confirm");
}
Loading

0 comments on commit 2cf2681

Please sign in to comment.