diff --git a/Cargo.lock b/Cargo.lock index 304984a8188a95d6fdd19bd6b36ae776d55ce64e..66df93eafc6132b144dd5fba104142031c811c75 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -481,7 +481,7 @@ dependencies = [ [[package]] name = "mkcss" -version = "0.1.6" +version = "0.2.0" dependencies = [ "clap", "clap-verbosity-flag", diff --git a/Cargo.toml b/Cargo.toml index 8f4e6460685be7f7ac441685b8013946edc63a25..8d0c8b293e8f75181ffb61f18c81188787c239e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mkcss" -version = "0.1.7" +version = "0.2.0" edition = "2021" license = "MIT" repository = "https://github.com/exact-rs/mkcss" diff --git a/Maidfile.toml b/Maidfile.toml index ca35a6e28a71626e12570f487c0d4ca4d20b0390..9cef377cd0503210bf54bd8873b4123a48be3f54 100644 --- a/Maidfile.toml +++ b/Maidfile.toml @@ -2,7 +2,7 @@ import = ["util/convert.toml"] [project] name = "mkcss" -version = "0.1.7" +version = "0.2.0" [tasks.build] info = "Build binaries" diff --git a/src/css.rs b/src/css.rs index 1654058d7ddf500058e09574b1d2925e975af505..5222dd23cfb9f8973e613df3da157ef10424ded9 100644 --- a/src/css.rs +++ b/src/css.rs @@ -43,16 +43,19 @@ pub fn create_stylesheet(classes: Vec<&String>, add_reset: bool) -> String { } "fg" => css_content.push_str(&format!(".{} {{ color: #{} !important }}\n", class, parts.get(1).unwrap_or(&""))), "bg" => css_content.push_str(&format!(".{} {{ background-color: #{} !important }}\n", class, parts.get(1).unwrap_or(&""))), + "bc" => css_content.push_str(&format!(".{} {{ border-color: #{} !important }}\n", class, parts.get(1).unwrap_or(&""))), _ => { let property_value = parts .get(if class.starts_with("-") { 2 } else { 1 }) .map(|&s| if class.starts_with("-") { format!("-{}", s) } else { s.to_string() }) .unwrap_or_else(String::new); - if let Some(&(_, property)) = util::MARGIN_STYLES.iter().find(|(prop_name, _)| prop_name == &name) { + if let Some(&(_, property)) = util::CONTROL_STYLES.iter().find(|(prop_name, _)| prop_name == &name) { let sign = if name.starts_with("-") { "-" } else { "" }; let declarations: Vec = property.split_whitespace().map(|p| format!("{}: {}{}px !important", p, sign, property_value)).collect(); css_content.push_str(&format!(".{} {{ {} }}\n", class, declarations.join("; "))); + } else if let Some(&(_, value)) = util::STYLES.iter().find(|(key, _)| key == *&class) { + css_content.push_str(&format!(".{} {{ {} }}\n", class, value)); } } } diff --git a/src/util.rs b/src/util.rs index 836044cc76118eb0041f7f7d834c0d7fcbce8eb7..562b0d85d83fc25f0db5e2dfa686394985a3351f 100644 --- a/src/util.rs +++ b/src/util.rs @@ -212,11 +212,11 @@ pub const STYLES: [(&str, &str); 273] = [ ("rounded-bl-2xl", "border-bottom-left-radius: 1rem"), ("rounded-bl-3xl", "border-bottom-left-radius: 1.5rem"), ("rounded-bl-full", "border-bottom-left-radius: 9999px"), + ("border", "border-style: solid; border-width: 1px"), ("border-0", "border-width: 0px"), ("border-2", "border-width: 2px"), ("border-4", "border-width: 4px"), ("border-8", "border-width: 8px"), - ("border", "border-width: 1px"), ("border-x-0", "border-left-width: 0px"), ("border-right-width:", "0px"), ("border-x-2", "border-left-width: 2px"), @@ -278,7 +278,7 @@ pub const STYLES: [(&str, &str); 273] = [ ("font-mono", MONO), ]; -pub const MARGIN_STYLES: [(&str, &str); 7] = [ +pub const CONTROL_STYLES: [(&str, &str); 14] = [ ("m", "margin"), ("mt", "margin-top"), ("mr", "margin-right"), @@ -286,4 +286,11 @@ pub const MARGIN_STYLES: [(&str, &str); 7] = [ ("ml", "margin-left"), ("mx", "margin-left margin-right"), ("my", "margin-top margin-bottom"), + ("p", "padding"), + ("pt", "padding-top"), + ("pr", "padding-right"), + ("pb", "padding-bottom"), + ("pl", "padding-left"), + ("px", "padding-left padding-right"), + ("py", "padding-top padding-bottom"), ];