aboutsummaryrefslogtreecommitdiffstats
path: root/src/themes.rs
diff options
context:
space:
mode:
authorSven-Hendrik Haase <svenstaro@gmail.com>2019-05-31 21:37:59 +0000
committerGitHub <noreply@github.com>2019-05-31 21:37:59 +0000
commitd49dfcf0bb02dcaa2c85d7be7cc3e998ff437174 (patch)
tree3747cf8c5be53a679250f20d454e920022ece0a9 /src/themes.rs
parentMerge pull request #130 from svenstaro/dependabot/cargo/structopt-0.2.16 (diff)
parentrefactor code (diff)
downloadminiserve-d49dfcf0bb02dcaa2c85d7be7cc3e998ff437174.tar.gz
miniserve-d49dfcf0bb02dcaa2c85d7be7cc3e998ff437174.zip
Merge pull request #128 from robatipoor/master
refactor code
Diffstat (limited to 'src/themes.rs')
-rw-r--r--src/themes.rs421
1 files changed, 210 insertions, 211 deletions
diff --git a/src/themes.rs b/src/themes.rs
index 65e9ab2..12ae7e3 100644
--- a/src/themes.rs
+++ b/src/themes.rs
@@ -2,6 +2,51 @@ 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")]
@@ -17,14 +62,13 @@ 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) -> String {
+ pub fn to_slug(self) -> &'static str {
match self {
ColorScheme::Archlinux => "archlinux",
ColorScheme::Zenburn => "zenburn",
ColorScheme::Monokai => "monokai",
ColorScheme::Squirrel => "squirrel",
}
- .to_string()
}
/// Returns wether a color scheme is dark
@@ -41,222 +85,177 @@ impl ColorScheme {
pub fn get_theme(self) -> Theme {
match self {
ColorScheme::Archlinux => Theme {
- background: "#383c4a".to_string(),
- text_color: "#fefefe".to_string(),
- directory_link_color: "#03a9f4".to_string(),
- file_link_color: "#ea95ff".to_string(),
- symlink_link_color: "#ff9800".to_string(),
- table_background: "#353946".to_string(),
- table_text_color: "#eeeeee".to_string(),
- table_header_background: "#5294e2".to_string(),
- table_header_text_color: "#eeeeee".to_string(),
- table_header_active_color: "#ffffff".to_string(),
- active_row_color: "#5194e259".to_string(),
- odd_row_background: "#404552".to_string(),
- even_row_background: "#4b5162".to_string(),
- root_link_color: "#abb2bb".to_string(),
- download_button_background: "#ea95ff".to_string(),
- download_button_background_hover: "#eea7ff".to_string(),
- download_button_link_color: "#ffffff".to_string(),
- download_button_link_color_hover: "#ffffff".to_string(),
- back_button_background: "#ea95ff".to_string(),
- back_button_background_hover: "#ea95ff".to_string(),
- back_button_link_color: "#ffffff".to_string(),
- back_button_link_color_hover: "#ffffff".to_string(),
- date_text_color: "#9ebbdc".to_string(),
- at_color: "#9ebbdc".to_string(),
- switch_theme_background: "#4b5162".to_string(),
- switch_theme_link_color: "#fefefe".to_string(),
- switch_theme_active: "#ea95ff".to_string(),
- switch_theme_border: "#6a728a".to_string(),
- change_theme_link_color: "#fefefe".to_string(),
- change_theme_link_color_hover: "#fefefe".to_string(),
- upload_text_color: "#fefefe".to_string(),
- upload_form_border_color: "#353946".to_string(),
- upload_form_background: "#4b5162".to_string(),
- upload_button_background: "#ea95ff".to_string(),
- upload_button_text_color: "#ffffff".to_string(),
- drag_background: "#3333338f".to_string(),
- drag_border_color: "#fefefe".to_string(),
- drag_text_color: "#fefefe".to_string(),
- size_background_color: "#5294e2".to_string(),
- size_text_color: "#fefefe".to_string(),
- error_color: "#e44b4b".to_string(),
+ 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".to_string(),
- text_color: "#efefef".to_string(),
- directory_link_color: "#f0dfaf".to_string(),
- file_link_color: "#87D6D5".to_string(),
- symlink_link_color: "#FFCCEE".to_string(),
- table_background: "#4a4949".to_string(),
- table_text_color: "#efefef".to_string(),
- table_header_background: "#7f9f7f".to_string(),
- table_header_text_color: "#efefef".to_string(),
- table_header_active_color: "#efef8f".to_string(),
- active_row_color: "#7e9f7f9c".to_string(),
- odd_row_background: "#777777".to_string(),
- even_row_background: "#5a5a5a".to_string(),
- root_link_color: "#dca3a3".to_string(),
- download_button_background: "#cc9393".to_string(),
- download_button_background_hover: "#dca3a3".to_string(),
- download_button_link_color: "#efefef".to_string(),
- download_button_link_color_hover: "#efefef".to_string(),
- back_button_background: "#cc9393".to_string(),
- back_button_background_hover: "#cc9393".to_string(),
- back_button_link_color: "#efefef".to_string(),
- back_button_link_color_hover: "#efefef".to_string(),
- date_text_color: "#cfbfaf".to_string(),
- at_color: "#cfbfaf".to_string(),
- switch_theme_background: "#4a4949".to_string(),
- switch_theme_link_color: "#efefef".to_string(),
- switch_theme_active: "#efef8f".to_string(),
- switch_theme_border: "#5a5a5a".to_string(),
- change_theme_link_color: "#efefef".to_string(),
- change_theme_link_color_hover: "#efefef".to_string(),
- upload_text_color: "#efefef".to_string(),
- upload_form_border_color: "#4a4949".to_string(),
- upload_form_background: "#777777".to_string(),
- upload_button_background: "#cc9393".to_string(),
- upload_button_text_color: "#efefef".to_string(),
- drag_background: "#3333338f".to_string(),
- drag_border_color: "#efefef".to_string(),
- drag_text_color: "#efefef".to_string(),
- size_background_color: "#7f9f7f".to_string(),
- size_text_color: "#efefef".to_string(),
- error_color: "#d06565".to_string(),
+ 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".to_string(),
- text_color: "#F8F8F2".to_string(),
- directory_link_color: "#F92672".to_string(),
- file_link_color: "#A6E22E".to_string(),
- symlink_link_color: "#FD971F".to_string(),
- table_background: "#3B3A32".to_string(),
- table_text_color: "#F8F8F0".to_string(),
- table_header_background: "#75715E".to_string(),
- table_header_text_color: "#F8F8F2".to_string(),
- table_header_active_color: "#E6DB74".to_string(),
- active_row_color: "#ae81fe3d".to_string(),
- odd_row_background: "#3E3D32".to_string(),
- even_row_background: "#49483E".to_string(),
- root_link_color: "#66D9EF".to_string(),
- download_button_background: "#AE81FF".to_string(),
- download_button_background_hover: "#c6a6ff".to_string(),
- download_button_link_color: "#F8F8F0".to_string(),
- download_button_link_color_hover: "#F8F8F0".to_string(),
- back_button_background: "#AE81FF".to_string(),
- back_button_background_hover: "#AE81FF".to_string(),
- back_button_link_color: "#F8F8F0".to_string(),
- back_button_link_color_hover: "#F8F8F0".to_string(),
- date_text_color: "#66D9EF".to_string(),
- at_color: "#66D9EF".to_string(),
- switch_theme_background: "#3B3A32".to_string(),
- switch_theme_link_color: "#F8F8F2".to_string(),
- switch_theme_active: "#A6E22E".to_string(),
- switch_theme_border: "#49483E".to_string(),
- change_theme_link_color: "#F8F8F2".to_string(),
- change_theme_link_color_hover: "#F8F8F2".to_string(),
- upload_text_color: "#F8F8F2".to_string(),
- upload_form_border_color: "#3B3A32".to_string(),
- upload_form_background: "#49483E".to_string(),
- upload_button_background: "#AE81FF".to_string(),
- upload_button_text_color: "#F8F8F0".to_string(),
- drag_background: "#3333338f".to_string(),
- drag_border_color: "#F8F8F2".to_string(),
- drag_text_color: "#F8F8F2".to_string(),
- size_background_color: "#75715E".to_string(),
- size_text_color: "#F8F8F2".to_string(),
- error_color: "#d02929".to_string(),
+ 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".to_string(),
- text_color: "#323232".to_string(),
- directory_link_color: "#d02474".to_string(),
- file_link_color: "#0086B3".to_string(),
- symlink_link_color: "#ED6A43".to_string(),
- table_background: "#ffffff".to_string(),
- table_text_color: "#323232".to_string(),
- table_header_background: "#323232".to_string(),
- table_header_text_color: "#F5F5F5".to_string(),
- table_header_active_color: "#FFFFFF".to_string(),
- active_row_color: "#f6f8fa".to_string(),
- odd_row_background: "#fbfbfb".to_string(),
- even_row_background: "#f2f2f2".to_string(),
- root_link_color: "#323232".to_string(),
- download_button_background: "#d02474".to_string(),
- download_button_background_hover: "#f52d8a".to_string(),
- download_button_link_color: "#FFFFFF".to_string(),
- download_button_link_color_hover: "#FFFFFF".to_string(),
- back_button_background: "#d02474".to_string(),
- back_button_background_hover: "#d02474".to_string(),
- back_button_link_color: "#FFFFFF".to_string(),
- back_button_link_color_hover: "#FFFFFF".to_string(),
- date_text_color: "#797979".to_string(),
- at_color: "#797979".to_string(),
- switch_theme_background: "#323232".to_string(),
- switch_theme_link_color: "#F5F5F5".to_string(),
- switch_theme_active: "#d02474".to_string(),
- switch_theme_border: "#49483E".to_string(),
- change_theme_link_color: "#F5F5F5".to_string(),
- change_theme_link_color_hover: "#F5F5F5".to_string(),
- upload_text_color: "#323232".to_string(),
- upload_form_border_color: "#d2d2d2".to_string(),
- upload_form_background: "#f2f2f2".to_string(),
- upload_button_background: "#d02474".to_string(),
- upload_button_text_color: "#FFFFFF".to_string(),
- drag_background: "#3333338f".to_string(),
- drag_border_color: "#ffffff".to_string(),
- drag_text_color: "#ffffff".to_string(),
- size_background_color: "#323232".to_string(),
- size_text_color: "#FFFFFF".to_string(),
- error_color: "#d02424".to_string(),
+ 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",
},
}
}
}
-
-/// Describes a theme
-pub struct Theme {
- pub background: String,
- pub text_color: String,
- pub directory_link_color: String,
- pub file_link_color: String,
- pub symlink_link_color: String,
- pub table_background: String,
- pub table_text_color: String,
- pub table_header_background: String,
- pub table_header_text_color: String,
- pub table_header_active_color: String,
- pub active_row_color: String,
- pub odd_row_background: String,
- pub even_row_background: String,
- pub root_link_color: String,
- pub download_button_background: String,
- pub download_button_background_hover: String,
- pub download_button_link_color: String,
- pub download_button_link_color_hover: String,
- pub back_button_background: String,
- pub back_button_background_hover: String,
- pub back_button_link_color: String,
- pub back_button_link_color_hover: String,
- pub date_text_color: String,
- pub at_color: String,
- pub switch_theme_background: String,
- pub switch_theme_link_color: String,
- pub switch_theme_active: String,
- pub switch_theme_border: String,
- pub change_theme_link_color: String,
- pub change_theme_link_color_hover: String,
- pub upload_text_color: String,
- pub upload_form_border_color: String,
- pub upload_form_background: String,
- pub upload_button_background: String,
- pub upload_button_text_color: String,
- pub drag_background: String,
- pub drag_border_color: String,
- pub drag_text_color: String,
- pub size_background_color: String,
- pub size_text_color: String,
- pub error_color: String,
-}