From 8ed18a551696ba4f89d7dfbdeaa879b21e079d33 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Mon, 1 Apr 2019 20:36:35 +0200 Subject: Color schemes --- src/themes.rs | 193 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) create mode 100644 src/themes.rs (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs new file mode 100644 index 0000000..5e8dc00 --- /dev/null +++ b/src/themes.rs @@ -0,0 +1,193 @@ +use serde::Deserialize; + +#[derive(Debug, Deserialize, Clone)] +pub enum ColorScheme { + #[serde(alias = "archlinux")] + ArchLinux, + + #[serde(alias = "zenburn")] + Zenburn, + + #[serde(alias = "monokai")] + Monokai, +} + +impl ColorScheme { + /// Returns the URL-compatible name of a color scheme + pub fn to_string(&self) -> String { + match &self { + ColorScheme::ArchLinux => "archlinux", + ColorScheme::Zenburn => "zenburn", + ColorScheme::Monokai => "monokai", + } + .to_string() + } + + /// Returns wether a color scheme is dark + pub fn is_dark(&self) -> bool { + match &self { + ColorScheme::ArchLinux => true, + ColorScheme::Zenburn => true, + ColorScheme::Monokai => true, + } + } + + /// Returns the name of a color scheme + pub fn get_name(&self) -> String { + match &self { + ColorScheme::ArchLinux => "Archlinux", + ColorScheme::Zenburn => "Zenburn", + ColorScheme::Monokai => "Monokai", + } + .to_string() + } + + /// Lists available color schemes + pub fn get_color_schemes() -> Vec { + vec![ + ColorScheme::ArchLinux, + ColorScheme::Zenburn, + ColorScheme::Monokai, + ] + } + + /// Retrieves the color palette associated to a color scheme + 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(), + field_color: "#859cb9".to_string(), + }, + 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(), + field_color: "#9fc3a1".to_string(), + }, + 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(), + field_color: "#ccc7a7".to_string(), + }, + } + } +} + +/// 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 field_color: String, +} -- cgit v1.2.3 From fae39ac193c9a0b55f85095f2cd4e53149c9c128 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Tue, 2 Apr 2019 07:24:49 +0200 Subject: Renamed ArchLinux to Archlinux --- src/themes.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index 5e8dc00..885c628 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -3,7 +3,7 @@ use serde::Deserialize; #[derive(Debug, Deserialize, Clone)] pub enum ColorScheme { #[serde(alias = "archlinux")] - ArchLinux, + Archlinux, #[serde(alias = "zenburn")] Zenburn, @@ -16,7 +16,7 @@ impl ColorScheme { /// Returns the URL-compatible name of a color scheme pub fn to_string(&self) -> String { match &self { - ColorScheme::ArchLinux => "archlinux", + ColorScheme::Archlinux => "archlinux", ColorScheme::Zenburn => "zenburn", ColorScheme::Monokai => "monokai", } @@ -26,7 +26,7 @@ impl ColorScheme { /// Returns wether a color scheme is dark pub fn is_dark(&self) -> bool { match &self { - ColorScheme::ArchLinux => true, + ColorScheme::Archlinux => true, ColorScheme::Zenburn => true, ColorScheme::Monokai => true, } @@ -35,7 +35,7 @@ impl ColorScheme { /// Returns the name of a color scheme pub fn get_name(&self) -> String { match &self { - ColorScheme::ArchLinux => "Archlinux", + ColorScheme::Archlinux => "Archlinux", ColorScheme::Zenburn => "Zenburn", ColorScheme::Monokai => "Monokai", } @@ -45,7 +45,7 @@ impl ColorScheme { /// Lists available color schemes pub fn get_color_schemes() -> Vec { vec![ - ColorScheme::ArchLinux, + ColorScheme::Archlinux, ColorScheme::Zenburn, ColorScheme::Monokai, ] @@ -54,7 +54,7 @@ impl ColorScheme { /// Retrieves the color palette associated to a color scheme pub fn get_theme(self) -> Theme { match self { - ColorScheme::ArchLinux => Theme { + ColorScheme::Archlinux => Theme { background: "#383c4a".to_string(), text_color: "#fefefe".to_string(), directory_link_color: "#03a9f4".to_string(), -- cgit v1.2.3 From 9f20b666a595e7c844d9707b7ccf202662d8322f Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Tue, 2 Apr 2019 20:18:37 +0200 Subject: Added light theme --- src/themes.rs | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index 885c628..f38814e 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -10,6 +10,9 @@ pub enum ColorScheme { #[serde(alias = "monokai")] Monokai, + + #[serde(alias = "squirrel")] + Squirrel, } impl ColorScheme { @@ -19,6 +22,7 @@ impl ColorScheme { ColorScheme::Archlinux => "archlinux", ColorScheme::Zenburn => "zenburn", ColorScheme::Monokai => "monokai", + ColorScheme::Squirrel => "squirrel", } .to_string() } @@ -29,6 +33,7 @@ impl ColorScheme { ColorScheme::Archlinux => true, ColorScheme::Zenburn => true, ColorScheme::Monokai => true, + ColorScheme::Squirrel => false, } } @@ -38,6 +43,7 @@ impl ColorScheme { ColorScheme::Archlinux => "Archlinux", ColorScheme::Zenburn => "Zenburn", ColorScheme::Monokai => "Monokai", + ColorScheme::Squirrel => "Squirrel", } .to_string() } @@ -48,6 +54,7 @@ impl ColorScheme { ColorScheme::Archlinux, ColorScheme::Zenburn, ColorScheme::Monokai, + ColorScheme::Squirrel, ] } @@ -153,6 +160,39 @@ impl ColorScheme { change_theme_link_color_hover: "#F8F8F2".to_string(), field_color: "#ccc7a7".to_string(), }, + 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: "#F5F5F5".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: "#F8F8F0".to_string(), + download_button_link_color_hover: "#F8F8F0".to_string(), + back_button_background: "#d02474".to_string(), + back_button_background_hover: "#d02474".to_string(), + back_button_link_color: "#F8F8F0".to_string(), + back_button_link_color_hover: "#F8F8F0".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(), + field_color: "#797979".to_string(), + }, } } } -- cgit v1.2.3 From 0304ea92390c06ccbbd7d29a88ecedc9718d72c2 Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Wed, 3 Apr 2019 20:07:33 +0200 Subject: Added CLI argument to set default theme --- src/themes.rs | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index f38814e..d04eab2 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -1,18 +1,15 @@ use serde::Deserialize; +use structopt::clap::{_clap_count_exprs, arg_enum}; -#[derive(Debug, Deserialize, Clone)] -pub enum ColorScheme { - #[serde(alias = "archlinux")] - Archlinux, - - #[serde(alias = "zenburn")] - Zenburn, - - #[serde(alias = "monokai")] - Monokai, - - #[serde(alias = "squirrel")] - Squirrel, +arg_enum! { + #[derive(Debug, Deserialize, Clone)] + #[serde(rename_all = "lowercase")] + pub enum ColorScheme { + Archlinux, + Zenburn, + Monokai, + Squirrel, + } } impl ColorScheme { -- cgit v1.2.3 From b0ead295996015fef9ea285bbed78509a85c5bbe Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sat, 6 Apr 2019 20:49:02 +0200 Subject: Improved mobile view --- src/themes.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index 917e56e..72bdcfa 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -89,7 +89,6 @@ impl ColorScheme { switch_theme_border: "#6a728a".to_string(), change_theme_link_color: "#fefefe".to_string(), change_theme_link_color_hover: "#fefefe".to_string(), - field_color: "#859cb9".to_string(), upload_text_color: "#fefefe".to_string(), upload_form_border_color: "#353946".to_string(), upload_form_background: "#4b5162".to_string(), @@ -98,6 +97,8 @@ impl ColorScheme { 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(), }, ColorScheme::Zenburn => Theme { background: "#3f3f3f".to_string(), @@ -130,7 +131,6 @@ impl ColorScheme { switch_theme_border: "#5a5a5a".to_string(), change_theme_link_color: "#efefef".to_string(), change_theme_link_color_hover: "#efefef".to_string(), - field_color: "#9fc3a1".to_string(), upload_text_color: "#efefef".to_string(), upload_form_border_color: "#4a4949".to_string(), upload_form_background: "#777777".to_string(), @@ -139,6 +139,8 @@ impl ColorScheme { 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(), }, ColorScheme::Monokai => Theme { background: "#272822".to_string(), @@ -171,7 +173,6 @@ impl ColorScheme { switch_theme_border: "#49483E".to_string(), change_theme_link_color: "#F8F8F2".to_string(), change_theme_link_color_hover: "#F8F8F2".to_string(), - field_color: "#ccc7a7".to_string(), upload_text_color: "#F8F8F2".to_string(), upload_form_border_color: "#3B3A32".to_string(), upload_form_background: "#49483E".to_string(), @@ -180,6 +181,8 @@ impl ColorScheme { 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(), }, ColorScheme::Squirrel => Theme { background: "#FFFFFF".to_string(), @@ -212,7 +215,6 @@ impl ColorScheme { switch_theme_border: "#49483E".to_string(), change_theme_link_color: "#F5F5F5".to_string(), change_theme_link_color_hover: "#F5F5F5".to_string(), - field_color: "#797979".to_string(), upload_text_color: "#323232".to_string(), upload_form_border_color: "#d2d2d2".to_string(), upload_form_background: "#f2f2f2".to_string(), @@ -221,6 +223,8 @@ impl ColorScheme { 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(), }, } } @@ -258,7 +262,6 @@ pub struct Theme { pub switch_theme_border: String, pub change_theme_link_color: String, pub change_theme_link_color_hover: String, - pub field_color: String, pub upload_text_color: String, pub upload_form_border_color: String, pub upload_form_background: String, @@ -267,4 +270,7 @@ pub struct Theme { pub drag_background: String, pub drag_border_color: String, pub drag_text_color: String, + pub size_background_color: String, + pub size_text_color: String, + } -- cgit v1.2.3 From 9e173a8d503287ff9aef8156adc7f4a4fd3892df Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sat, 6 Apr 2019 20:50:25 +0200 Subject: Cargo fmt --- src/themes.rs | 1 - 1 file changed, 1 deletion(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index 72bdcfa..dca656d 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -272,5 +272,4 @@ pub struct Theme { pub drag_text_color: String, pub size_background_color: String, pub size_text_color: String, - } -- cgit v1.2.3 From c24986640589df2aa5b2f7360cc8bea71ed49fbb Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sun, 7 Apr 2019 12:21:58 +0200 Subject: Use strum_macros::EnumIter instead of manually listing Enum variants --- src/themes.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index dca656d..8635c8f 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -1,8 +1,9 @@ use serde::Deserialize; use structopt::clap::{_clap_count_exprs, arg_enum}; +use strum_macros::EnumIter; arg_enum! { - #[derive(Debug, Deserialize, Clone)] + #[derive(Debug, Deserialize, Clone, EnumIter)] #[serde(rename_all = "lowercase")] pub enum ColorScheme { Archlinux, @@ -45,16 +46,6 @@ impl ColorScheme { .to_string() } - /// Lists available color schemes - pub fn get_color_schemes() -> Vec { - vec![ - ColorScheme::Archlinux, - ColorScheme::Zenburn, - ColorScheme::Monokai, - ColorScheme::Squirrel, - ] - } - /// Retrieves the color palette associated to a color scheme pub fn get_theme(self) -> Theme { match self { -- cgit v1.2.3 From bbdafc3e121942c95ba81db1cba30fe438d88dfb Mon Sep 17 00:00:00 2001 From: boasting-squirrel Date: Sun, 7 Apr 2019 13:27:25 +0200 Subject: Use strum to reduce boilerplate on ColorScheme enum + removed useless Debug derives --- src/themes.rs | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) (limited to 'src/themes.rs') diff --git a/src/themes.rs b/src/themes.rs index 8635c8f..328a2e8 100644 --- a/src/themes.rs +++ b/src/themes.rs @@ -3,7 +3,7 @@ use structopt::clap::{_clap_count_exprs, arg_enum}; use strum_macros::EnumIter; arg_enum! { - #[derive(Debug, Deserialize, Clone, EnumIter)] + #[derive(PartialEq, Deserialize, Clone, EnumIter)] #[serde(rename_all = "lowercase")] pub enum ColorScheme { Archlinux, @@ -15,7 +15,9 @@ arg_enum! { impl ColorScheme { /// Returns the URL-compatible name of a color scheme - pub fn to_string(&self) -> String { + /// 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 { match &self { ColorScheme::Archlinux => "archlinux", ColorScheme::Zenburn => "zenburn", @@ -35,17 +37,6 @@ impl ColorScheme { } } - /// Returns the name of a color scheme - pub fn get_name(&self) -> String { - match &self { - ColorScheme::Archlinux => "Archlinux", - ColorScheme::Zenburn => "Zenburn", - ColorScheme::Monokai => "Monokai", - ColorScheme::Squirrel => "Squirrel", - } - .to_string() - } - /// Retrieves the color palette associated to a color scheme pub fn get_theme(self) -> Theme { match self { -- cgit v1.2.3