mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 16:44:15 -05:00
fix: Image object-fit (#195)
This commit is contained in:
parent
9259bdc723
commit
ab3ea810de
2 changed files with 7 additions and 2 deletions
|
@ -3,7 +3,7 @@
|
||||||
```rust demo
|
```rust demo
|
||||||
view! {
|
view! {
|
||||||
<Image src="https://s3.bmp.ovh/imgs/2021/10/2c3b013418d55659.jpg" width="500px"/>
|
<Image src="https://s3.bmp.ovh/imgs/2021/10/2c3b013418d55659.jpg" width="500px"/>
|
||||||
<Image width="200px" height="200px"/>
|
<Image src="https://s3.bmp.ovh/imgs/2021/10/2c3b013418d55659.jpg" width="200px" height="200px" object_fit="cover"/>
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,12 @@ pub fn Image(
|
||||||
style.push_str(&format!("border-radius: {border_radius};"))
|
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
|
style
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,7 +44,6 @@ pub fn Image(
|
||||||
src=src.map(|s| move || s.get())
|
src=src.map(|s| move || s.get())
|
||||||
alt=alt.map(|a| move || a.get())
|
alt=alt.map(|a| move || a.get())
|
||||||
style=style
|
style=style
|
||||||
object_fit=object_fit.map(|o| move || o.get())
|
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue