From ab3ea810de13ae11f4058283e8efb28a59fc9467 Mon Sep 17 00:00:00 2001 From: luoxiaozero <48741584+luoxiaozero@users.noreply.github.com> Date: Sat, 18 May 2024 16:08:44 +0800 Subject: [PATCH] fix: Image object-fit (#195) --- demo_markdown/docs/image/mod.md | 2 +- thaw/src/image/mod.rs | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/demo_markdown/docs/image/mod.md b/demo_markdown/docs/image/mod.md index 46bee1f..0a5d888 100644 --- a/demo_markdown/docs/image/mod.md +++ b/demo_markdown/docs/image/mod.md @@ -3,7 +3,7 @@ ```rust demo view! { - + } ``` diff --git a/thaw/src/image/mod.rs b/thaw/src/image/mod.rs index 46eaa75..5cf8337 100644 --- a/thaw/src/image/mod.rs +++ b/thaw/src/image/mod.rs @@ -29,6 +29,12 @@ pub fn Image( style.push_str(&format!("border-radius: {border_radius};")) } + if let Some(object_fit) = object_fit.as_ref().map(|object_fit| object_fit.get()) { + if !object_fit.is_empty() { + style.push_str(&format!("object-fit: {object_fit};")) + } + } + style }; @@ -38,7 +44,6 @@ pub fn Image( src=src.map(|s| move || s.get()) alt=alt.map(|a| move || a.get()) style=style - object_fit=object_fit.map(|o| move || o.get()) /> } }