mottes_floem_components/theme.rs
1//! # Theme
2//!
3//! If you just want to have something work fast use `Theme::dark()`, `Theme::light()` or
4//! `Theme::default()` (equivalent to the dark theme.)
5//!
6//! ## Constructing your own theme
7//!
8//! `Theme` is a struct wrapping [base 16 color schemes](https://github.com/chriskempson/base16).
9//! This means that constructing a color scheme is extremely easy, just use your own hex values
10//! in a `Theme` instance. For example, this is the code for the dark theme in `Theme::dark()`:
11//!
12//! ```no_run
13//! # use mottes_floem_components::theme::Theme;
14//! /// https://github.com/rebelot/kanagawa.nvim/blob/master/extras/base16/kanagawa.yaml
15//! const KANAGAWA_WAVE: Theme = Theme {
16//! base00: "#1F1F28",
17//! base01: "#2A2A37",
18//! base02: "#223249",
19//! base03: "#727169",
20//! base04: "#C8C093",
21//! base05: "#DCD7BA",
22//! base06: "#938AA9",
23//! base07: "#363646",
24//! base08: "#C34043",
25//! base09: "#FFA066",
26//! base0a: "#DCA561",
27//! base0b: "#98BB6C",
28//! base0c: "#7FB4CA",
29//! base0d: "#7E9CD8",
30//! base0e: "#957FB8",
31//! base0f: "#D27E99",
32//! };
33//! ```
34//!
35//! Since every `Theme` instance needs to have a `'static` lifetime for everything
36//! in the `views` module, it is recommended to make your own theme a constant as well.
37
38/// https://github.com/rebelot/kanagawa.nvim/blob/master/extras/base16/kanagawa.yaml
39const KANAGAWA_WAVE: Theme = Theme {
40 base00: "#1F1F28",
41 base01: "#2A2A37",
42 base02: "#223249",
43 base03: "#727169",
44 base04: "#C8C093",
45 base05: "#DCD7BA",
46 base06: "#938AA9",
47 base07: "#363646",
48 base08: "#C34043",
49 base09: "#FFA066",
50 base0a: "#DCA561",
51 base0b: "#98BB6C",
52 base0c: "#7FB4CA",
53 base0d: "#7E9CD8",
54 base0e: "#957FB8",
55 base0f: "#D27E99",
56};
57
58/// Slightly modified version of the atelier etsuary light theme.
59/// Originally ported by http://atelierbramdehaan.nl.
60const ATELIER_ESTUARY_LIGHT: Theme = Theme {
61 base00: "#f4f3ec",
62 base01: "#e7e6df",
63 base02: "#929181",
64 base03: "#595745",
65 base04: "#6c6b5a",
66 base05: "#5f5e4e",
67 base06: "#302f27",
68 base07: "#22221b",
69 base08: "#ba6236",
70 base09: "#ae7313",
71 base0a: "#a5980d",
72 base0b: "#7d9726",
73 base0c: "#5b9d48",
74 base0d: "#36a166",
75 base0e: "#5f9182",
76 base0f: "#9d6c7c",
77};
78
79/// `Theme` is a [base 16 color scheme](https://github.com/chriskempson/base16).
80/// String values have to be compliant with [floems color parse function](https://docs.rs/floem/latest/floem/prelude/struct.Color.html#method.parse)
81/// (e.g. "#FFFFFF").
82#[derive(Debug, Clone, Copy)]
83pub struct Theme<'a> {
84 pub base00: &'a str,
85 pub base01: &'a str,
86 pub base02: &'a str,
87 pub base03: &'a str,
88 pub base04: &'a str,
89 pub base05: &'a str,
90 pub base06: &'a str,
91 pub base07: &'a str,
92 pub base08: &'a str,
93 pub base09: &'a str,
94 pub base0a: &'a str,
95 pub base0b: &'a str,
96 pub base0c: &'a str,
97 pub base0d: &'a str,
98 pub base0e: &'a str,
99 pub base0f: &'a str,
100}
101
102impl Theme<'_> {
103 pub fn dark() -> Self {
104 KANAGAWA_WAVE
105 }
106
107 pub fn light() -> Self {
108 ATELIER_ESTUARY_LIGHT
109 }
110}
111
112impl Default for Theme<'_> {
113 fn default() -> Self {
114 KANAGAWA_WAVE
115 }
116}