feat: swap css/theme uses. theme is now primary css

This commit is contained in:
imgurbot12 2023-08-20 10:27:18 -07:00
parent 5fb383851c
commit 59e8cf6c22
7 changed files with 22 additions and 22 deletions

View File

@ -1,13 +1,13 @@
#!/bin/sh #!/bin/sh
CSS=`realpath "$(dirname $0)/css/powermenu.css"`
SELF=`realpath $0` SELF=`realpath $0`
THEME=`realpath "$(dirname $0)/themes/powermenu.css"`
RMENU=${RMENU:-"rmenu"} RMENU=${RMENU:-"rmenu"}
#: desc => generate options for basic operation #: desc => generate options for basic operation
main_options() { main_options() {
rmenu-build options \ rmenu-build options \
-t $THEME \ -C $CSS \
-n ArrowRight -p ArrowLeft \ -n ArrowRight -p ArrowLeft \
-w 550 -h 150 -M 0 -w 550 -h 150 -M 0
} }
@ -15,7 +15,7 @@ main_options() {
#: desc => generate options for confirm operation #: desc => generate options for confirm operation
confirm_options() { confirm_options() {
rmenu-build options \ rmenu-build options \
-t $THEME \ -C $CSS \
-n ArrowRight -p ArrowLeft \ -n ArrowRight -p ArrowLeft \
-w 300 -h 150 -M 0 -w 300 -h 150 -M 0
} }

View File

@ -121,8 +121,8 @@ impl Into<Entry> for EntryArgs {
#[derive(Debug, Args)] #[derive(Debug, Args)]
struct OptionArgs { struct OptionArgs {
/// Override Applicaiton Theme /// Override Applicaiton Theme
#[arg(short, long)] #[arg(short = 'C', long)]
pub theme: Option<String>, pub css: Option<String>,
// search settings // search settings
/// Override Default Placeholder /// Override Default Placeholder
#[arg(short = 'P', long)] #[arg(short = 'P', long)]
@ -176,7 +176,7 @@ struct OptionArgs {
impl Into<Options> for OptionArgs { impl Into<Options> for OptionArgs {
fn into(self) -> Options { fn into(self) -> Options {
Options { Options {
theme: self.theme, css: self.css,
placeholder: self.placeholder, placeholder: self.placeholder,
search_restrict: self.search_restrict, search_restrict: self.search_restrict,
search_min_length: self.search_min_length, search_min_length: self.search_min_length,

View File

@ -87,7 +87,7 @@ impl Entry {
pub struct Options { pub struct Options {
// base settings // base settings
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub theme: Option<String>, pub css: Option<String>,
// search settings // search settings
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
pub placeholder: Option<String>, pub placeholder: Option<String>,

View File

@ -54,12 +54,12 @@ pub struct Args {
/// Override default configuration path /// Override default configuration path
#[arg(short, long)] #[arg(short, long)]
config: Option<String>, config: Option<String>,
/// Override base css styling /// Override base css theme styling
#[arg(long, default_value_t=String::from(DEFAULT_CSS))] #[arg(long, default_value_t=String::from(DEFAULT_CSS))]
css: String, theme: String,
/// Include additional css settings for themeing /// Include additional css settings
#[arg(long)] #[arg(long)]
theme: Option<String>, css: Option<String>,
// root config settings // root config settings
/// Override terminal command /// Override terminal command
@ -254,9 +254,9 @@ impl Args {
config config
} }
/// Load CSS or Default /// Load CSS Theme or Default
pub fn get_css(&self) -> String { pub fn get_theme(&self) -> String {
let path = shellexpand::tilde(&self.css).to_string(); let path = shellexpand::tilde(&self.theme).to_string();
match read_to_string(&path) { match read_to_string(&path) {
Ok(css) => css, Ok(css) => css,
Err(err) => { Err(err) => {
@ -266,10 +266,10 @@ impl Args {
} }
} }
/// Load CSS Theme or Default /// Load Additional CSS or Default
pub fn get_theme(&self) -> String { pub fn get_css(&self) -> String {
if let Some(theme) = self.theme.as_ref() { if let Some(css) = self.css.as_ref() {
let path = shellexpand::tilde(&theme).to_string(); let path = shellexpand::tilde(&css).to_string();
match read_to_string(&path) { match read_to_string(&path) {
Ok(theme) => return theme, Ok(theme) => return theme,
Err(err) => log::error!("Failed to load Theme: {err:?}"), Err(err) => log::error!("Failed to load Theme: {err:?}"),
@ -293,7 +293,7 @@ impl Args {
Message::Entry(entry) => v.push(entry), Message::Entry(entry) => v.push(entry),
Message::Options(options) => { Message::Options(options) => {
// base settings // base settings
self.theme = self.theme.clone().or(options.theme); self.css = self.css.clone().or(options.css);
// search settings // search settings
cli_replace!(c.search.placeholder, options.placeholder); cli_replace!(c.search.placeholder, options.placeholder);
cli_replace!(c.search.restrict, options.search_restrict); cli_replace!(c.search.restrict, options.search_restrict);

View File

@ -241,8 +241,8 @@ fn App<'a>(cx: Scope<App>) -> Element {
// complete final rendering // complete final rendering
cx.render(rsx! { cx.render(rsx! {
style { DEFAULT_CSS_CONTENT } style { DEFAULT_CSS_CONTENT }
style { "{cx.props.css}" }
style { "{cx.props.theme}" } style { "{cx.props.theme}" }
style { "{cx.props.css}" }
div { div {
id: "content", id: "content",
class: "content", class: "content",

View File

@ -20,9 +20,9 @@ static DEFAULT_CSS_CONTENT: &'static str = include_str!("../public/default.css")
pub struct App { pub struct App {
css: String, css: String,
name: String, name: String,
theme: String,
entries: Vec<Entry>, entries: Vec<Entry>,
config: config::Config, config: config::Config,
theme: String,
} }
//TODO: how should scripting work? //TODO: how should scripting work?
@ -66,9 +66,9 @@ fn main() -> cli::Result<()> {
gui::run(App { gui::run(App {
name: "rmenu".to_owned(), name: "rmenu".to_owned(),
css, css,
theme,
entries, entries,
config, config,
theme,
}); });
Ok(()) Ok(())