Skip to content

Commit f7ff056

Browse files
committed
Fix optimize
1 parent c9593ce commit f7ff056

File tree

4 files changed

+6
-7
lines changed

4 files changed

+6
-7
lines changed

libs/css/src/constant.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ pub(super) static DOUBLE_SEPARATOR: phf::Set<&str> = phf_set! {
7878

7979
pub(super) static F_SPACE_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"\s*,\s*").unwrap());
8080
pub(super) static F_DOT_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\b|,)0\.(\d+)").unwrap());
81-
pub(super) static DOT_ZERO_RE: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\b|,)-?0\.0+").unwrap());
81+
pub(super) static DOT_ZERO_RE: Lazy<Regex> =
82+
Lazy::new(|| Regex::new(r"(\b|,)-?0\.0+([^\d])").unwrap());
8283

8384
pub(super) static COLOR_HASH: Lazy<Regex> = Lazy::new(|| Regex::new(r"#([0-9a-zA-Z]+)").unwrap());
8485
pub(super) static ZERO_RE: Lazy<Regex> =

libs/css/src/optimize_value.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ pub fn optimize_value(value: &str) -> String {
1414
.to_string();
1515
}
1616
if ret.contains("0") {
17-
ret = DOT_ZERO_RE.replace_all(&ret, "0").to_string();
17+
ret = DOT_ZERO_RE.replace_all(&ret, "${1}0${2}").to_string();
1818
ret = F_DOT_RE.replace_all(&ret, "${1}.${2}").to_string();
1919
ret = ZERO_RE.replace_all(&ret, "${1}0").to_string();
2020
}
@@ -86,10 +86,13 @@ mod tests {
8686
#[case("0vh 0vh", "0 0")]
8787
#[case("0vw 0vw", "0 0")]
8888
#[case("-0vw -0vw", "0 0")]
89+
#[case("-0.2em", "-.2em")]
90+
#[case("-0.02em", "-.02em")]
8991
#[case("scale(0px)", "scale(0)")]
9092
#[case("scale(-0px)", "scale(0)")]
9193
#[case("scale(-0px);", "scale(0)")]
9294
#[case("rgba(255, 0, 0, 0.5)", "rgba(255,0,0,.5)")]
95+
#[case("rgba(0.0,0.0,0.0,0.5)", "rgba(0,0,0,.5)")]
9396
#[case("red;", "red")]
9497
#[case("translate(0px)", "translate(0)")]
9598
#[case("translate(-0px,0px)", "translate(0,0)")]

libs/extractor/src/css_utils.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ pub fn css_to_style<'a>(
3838

3939
if input.contains('{') {
4040
while let Some(start) = input.find('{') {
41-
println!("input: {}", input);
4241
let rest = &input[start + 1..];
4342

4443
let end = if selector.is_none() {

libs/sheet/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ impl StyleSheet {
229229
}
230230

231231
pub fn set_theme(&mut self, theme: Theme) {
232-
println!("{:?}", theme);
233232
self.theme = theme;
234233
}
235234

@@ -255,9 +254,6 @@ impl StyleSheet {
255254
self.theme.colors.keys().for_each(|key| {
256255
theme_keys.insert(key.clone());
257256
});
258-
println!("{:?}", color_keys);
259-
println!("{:?}", typography_keys);
260-
println!("{:?}", theme_keys);
261257

262258
if color_keys.is_empty() && typography_keys.is_empty() {
263259
String::new()

0 commit comments

Comments
 (0)