use serde::Deserialize; use structopt::clap::arg_enum; use strum_macros::EnumIter; /// Describes a theme pub struct Theme { pub background: &'static str, pub text_color: &'static str, pub directory_link_color: &'static str, pub file_link_color: &'static str, pub symlink_link_color: &'static str, pub table_background: &'static str, pub table_text_color: &'static str, pub table_header_background: &'static str, pub table_header_text_color: &'static str, pub table_header_active_color: &'static str, pub active_row_color: &'static str, pub odd_row_background: &'static str, pub even_row_background: &'static str, pub root_link_color: &'static str, pub download_button_background: &'static str, pub download_button_background_hover: &'static str, pub download_button_link_color: &'static str, pub download_button_link_color_hover: &'static str, pub back_button_background: &'static str, pub back_button_background_hover: &'static str, pub back_button_link_color: &'static str, pub back_button_link_color_hover: &'static str, pub date_text_color: &'static str, pub at_color: &'static str, pub switch_theme_background: &'static str, pub switch_theme_link_color: &'static str, pub switch_theme_active: &'static str, pub switch_theme_border: &'static str, pub change_theme_link_color: &'static str, pub change_theme_link_color_hover: &'static str, pub upload_text_color: &'static str, pub upload_form_border_color: &'static str, pub upload_form_background: &'static str, pub upload_button_background: &'static str, pub upload_button_text_color: &'static str, pub drag_background: &'static str, pub drag_border_color: &'static str, pub drag_text_color: &'static str, pub size_background_color: &'static str, pub size_text_color: &'static str, pub error_color: &'static str, } arg_enum! { #[derive(PartialEq, Deserialize, Clone, EnumIter, Copy)] #[serde(rename_all = "lowercase")] pub enum ColorScheme { Archlinux, Zenburn, Monokai, Squirrel, } } impl ColorScheme { /// Returns the URL-compatible name of a color scheme /// This must correspond to the name of the variant, in lowercase /// See https://github.com/svenstaro/miniserve/pull/55 for explanations pub fn to_slug(self) -> &'static str { match self { ColorScheme::Archlinux => "archlinux", ColorScheme::Zenburn => "zenburn", ColorScheme::Monokai => "monokai", ColorScheme::Squirrel => "squirrel", } } /// Returns wether a color scheme is dark pub fn is_dark(self) -> bool { match self { ColorScheme::Archlinux => true, ColorScheme::Zenburn => true, ColorScheme::Monokai => true, ColorScheme::Squirrel => false, } } /// Retrieves the color palette associated to a color scheme pub fn get_theme(self) -> Theme { match self { ColorScheme::Archlinux => Theme { background: "#383c4a", text_color: "#fefefe", directory_link_color: "#03a9f4", file_link_color: "#ea95ff", symlink_link_color: "#ff9800", table_background: "#353946", table_text_color: "#eeeeee", table_header_background: "#5294e2", table_header_text_color: "#eeeeee", table_header_active_color: "#ffffff", active_row_color: "#5194e259", odd_row_background: "#404552", even_row_background: "#4b5162", root_link_color: "#abb2bb", download_button_background: "#ea95ff", download_button_background_hover: "#eea7ff", download_button_link_color: "#ffffff", download_button_link_color_hover: "#ffffff", back_button_background: "#ea95ff", back_button_background_hover: "#ea95ff", back_button_link_color: "#ffffff", back_button_link_color_hover: "#ffffff", date_text_color: "#9ebbdc", at_color: "#9ebbdc", switch_theme_background: "#4b5162", switch_theme_link_color: "#fefefe", switch_theme_active: "#ea95ff", switch_theme_border: "#6a728a", change_theme_link_color: "#fefefe", change_theme_link_color_hover: "#fefefe", upload_text_color: "#fefefe", upload_form_border_color: "#353946", upload_form_background: "#4b5162", upload_button_background: "#ea95ff", upload_button_text_color: "#ffffff", drag_background: "#3333338f", drag_border_color: "#fefefe", drag_text_color: "#fefefe", size_background_color: "#5294e2", size_text_color: "#fefefe", error_color: "#e44b4b", }, ColorScheme::Zenburn => Theme { background: "#3f3f3f", text_color: "#efefef", directory_link_color: "#f0dfaf", file_link_color: "#87D6D5", symlink_link_color: "#FFCCEE", table_background: "#4a4949", table_text_color: "#efefef", table_header_background: "#7f9f7f", table_header_text_color: "#efefef", table_header_active_color: "#efef8f", active_row_color: "#7e9f7f9c", odd_row_background: "#777777", even_row_background: "#5a5a5a", root_link_color: "#dca3a3", download_button_background: "#cc9393", download_button_background_hover: "#dca3a3", download_button_link_color: "#efefef", download_button_link_color_hover: "#efefef", back_button_background: "#cc9393", back_button_background_hover: "#cc9393", back_button_link_color: "#efefef", back_button_link_color_hover: "#efefef", date_text_color: "#cfbfaf", at_color: "#cfbfaf", switch_theme_background: "#4a4949", switch_theme_link_color: "#efefef", switch_theme_active: "#efef8f", switch_theme_border: "#5a5a5a", change_theme_link_color: "#efefef", change_theme_link_color_hover: "#efefef", upload_text_color: "#efefef", upload_form_border_color: "#4a4949", upload_form_background: "#777777", upload_button_background: "#cc9393", upload_button_text_color: "#efefef", drag_background: "#3333338f", drag_border_color: "#efefef", drag_text_color: "#efefef", size_background_color: "#7f9f7f", size_text_color: "#efefef", error_color: "#d06565", }, ColorScheme::Monokai => Theme { background: "#272822", text_color: "#F8F8F2", directory_link_color: "#F92672", file_link_color: "#A6E22E", symlink_link_color: "#FD971F", table_background: "#3B3A32", table_text_color: "#F8F8F0", table_header_background: "#75715E", table_header_text_color: "#F8F8F2", table_header_active_color: "#E6DB74", active_row_color: "#ae81fe3d", odd_row_background: "#3E3D32", even_row_background: "#49483E", root_link_color: "#66D9EF", download_button_background: "#AE81FF", download_button_background_hover: "#c6a6ff", download_button_link_color: "#F8F8F0", download_button_link_color_hover: "#F8F8F0", back_button_background: "#AE81FF", back_button_background_hover: "#AE81FF", back_button_link_color: "#F8F8F0", back_button_link_color_hover: "#F8F8F0", date_text_color: "#66D9EF", at_color: "#66D9EF", switch_theme_background: "#3B3A32", switch_theme_link_color: "#F8F8F2", switch_theme_active: "#A6E22E", switch_theme_border: "#49483E", change_theme_link_color: "#F8F8F2", change_theme_link_color_hover: "#F8F8F2", upload_text_color: "#F8F8F2", upload_form_border_color: "#3B3A32", upload_form_background: "#49483E", upload_button_background: "#AE81FF", upload_button_text_color: "#F8F8F0", drag_background: "#3333338f", drag_border_color: "#F8F8F2", drag_text_color: "#F8F8F2", size_background_color: "#75715E", size_text_color: "#F8F8F2", error_color: "#d02929", }, ColorScheme::Squirrel => Theme { background: "#FFFFFF", text_color: "#323232", directory_link_color: "#d02474", file_link_color: "#0086B3", symlink_link_color: "#ED6A43", table_background: "#ffffff", table_text_color: "#323232", table_header_background: "#323232", table_header_text_color: "#F5F5F5", table_header_active_color: "#FFFFFF", active_row_color: "#f6f8fa", odd_row_background: "#fbfbfb", even_row_background: "#f2f2f2", root_link_color: "#323232", download_button_background: "#d02474", download_button_background_hover: "#f52d8a", download_button_link_color: "#FFFFFF", download_button_link_color_hover: "#FFFFFF", back_button_background: "#d02474", back_button_background_hover: "#d02474", back_button_link_color: "#FFFFFF", back_button_link_color_hover: "#FFFFFF", date_text_color: "#797979", at_color: "#797979", switch_theme_background: "#323232", switch_theme_link_color: "#F5F5F5", switch_theme_active: "#d02474", switch_theme_border: "#49483E", change_theme_link_color: "#F5F5F5", change_theme_link_color_hover: "#F5F5F5", upload_text_color: "#323232", upload_form_border_color: "#d2d2d2", upload_form_background: "#f2f2f2", upload_button_background: "#d02474", upload_button_text_color: "#FFFFFF", drag_background: "#3333338f", drag_border_color: "#ffffff", drag_text_color: "#ffffff", size_background_color: "#323232", size_text_color: "#FFFFFF", error_color: "#d02424", }, } } }