mottes-floem-components 0.1.0

Some styled components for floem.
Documentation
//! # Theme
//!
//! If you just want to have something work fast use `Theme::dark()`, `Theme::light()` or
//! `Theme::default()` (equivalent to the dark theme.)
//!
//! ## Constructing your own theme
//!
//! `Theme` is a struct wrapping [base 16 color schemes](https://github.com/chriskempson/base16).
//! This means that constructing a color scheme is extremely easy, just use your own hex values
//! in a `Theme` instance. For example, this is the code for the dark theme in `Theme::dark()`:
//!
//! ```no_run
//! # use mottes_floem_components::theme::Theme;
//! /// https://github.com/rebelot/kanagawa.nvim/blob/master/extras/base16/kanagawa.yaml
//! const KANAGAWA_WAVE: Theme = Theme {
//!     base00: "#1F1F28",
//!     base01: "#2A2A37",
//!     base02: "#223249",
//!     base03: "#727169",
//!     base04: "#C8C093",
//!     base05: "#DCD7BA",
//!     base06: "#938AA9",
//!     base07: "#363646",
//!     base08: "#C34043",
//!     base09: "#FFA066",
//!     base0a: "#DCA561",
//!     base0b: "#98BB6C",
//!     base0c: "#7FB4CA",
//!     base0d: "#7E9CD8",
//!     base0e: "#957FB8",
//!     base0f: "#D27E99",
//! };
//! ```
//!
//! Since every `Theme` instance needs to have a `'static` lifetime for everything
//! in the `views` module, it is recommended to make your own theme a constant as well.

/// https://github.com/rebelot/kanagawa.nvim/blob/master/extras/base16/kanagawa.yaml
const KANAGAWA_WAVE: Theme = Theme {
    base00: "#1F1F28",
    base01: "#2A2A37",
    base02: "#223249",
    base03: "#727169",
    base04: "#C8C093",
    base05: "#DCD7BA",
    base06: "#938AA9",
    base07: "#363646",
    base08: "#C34043",
    base09: "#FFA066",
    base0a: "#DCA561",
    base0b: "#98BB6C",
    base0c: "#7FB4CA",
    base0d: "#7E9CD8",
    base0e: "#957FB8",
    base0f: "#D27E99",
};

/// Slightly modified version of the atelier etsuary light theme.
/// Originally ported by http://atelierbramdehaan.nl.
const ATELIER_ESTUARY_LIGHT: Theme = Theme {
    base00: "#f4f3ec",
    base01: "#e7e6df",
    base02: "#929181",
    base03: "#595745",
    base04: "#6c6b5a",
    base05: "#5f5e4e",
    base06: "#302f27",
    base07: "#22221b",
    base08: "#ba6236",
    base09: "#ae7313",
    base0a: "#a5980d",
    base0b: "#7d9726",
    base0c: "#5b9d48",
    base0d: "#36a166",
    base0e: "#5f9182",
    base0f: "#9d6c7c",
};

/// `Theme` is a [base 16 color scheme](https://github.com/chriskempson/base16).
/// String values have to be compliant with [floems color parse function](https://docs.rs/floem/latest/floem/prelude/struct.Color.html#method.parse)
/// (e.g. "#FFFFFF").
#[derive(Debug, Clone, Copy)]
pub struct Theme<'a> {
    pub base00: &'a str,
    pub base01: &'a str,
    pub base02: &'a str,
    pub base03: &'a str,
    pub base04: &'a str,
    pub base05: &'a str,
    pub base06: &'a str,
    pub base07: &'a str,
    pub base08: &'a str,
    pub base09: &'a str,
    pub base0a: &'a str,
    pub base0b: &'a str,
    pub base0c: &'a str,
    pub base0d: &'a str,
    pub base0e: &'a str,
    pub base0f: &'a str,
}

impl Theme<'_> {
    pub fn dark() -> Self {
        KANAGAWA_WAVE
    }

    pub fn light() -> Self {
        ATELIER_ESTUARY_LIGHT
    }
}

impl Default for Theme<'_> {
    fn default() -> Self {
        KANAGAWA_WAVE
    }
}