Skip to content
Snippets Groups Projects
Verified Commit c089d735 authored by theMackabu's avatar theMackabu :smile_cat:
Browse files

support rounded classes

parent f5e7e961
Branches master
No related tags found
No related merge requests found
......@@ -481,7 +481,7 @@ dependencies = [
[[package]]
name = "mkcss"
version = "0.1.6"
version = "0.2.0"
dependencies = [
"clap",
"clap-verbosity-flag",
......
[package]
name = "mkcss"
version = "0.1.7"
version = "0.2.0"
edition = "2021"
license = "MIT"
repository = "https://github.com/exact-rs/mkcss"
......
......@@ -2,7 +2,7 @@ import = ["util/convert.toml"]
[project]
name = "mkcss"
version = "0.1.7"
version = "0.2.0"
[tasks.build]
info = "Build binaries"
......
......@@ -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<String> = 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));
}
}
}
......
......@@ -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"),
];
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment