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

View File

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

View File

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

View File

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

View File

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

View File

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