diff --git a/demo_markdown/docs/image/mod.md b/demo_markdown/docs/image/mod.md
index 46bee1f..6540b3f 100644
--- a/demo_markdown/docs/image/mod.md
+++ b/demo_markdown/docs/image/mod.md
@@ -7,6 +7,17 @@ view! {
}
```
+### Shape
+
+```rust demo
+view! {
+
+
+
+}
+```
+
+
### Image Props
| Name | Type | Default | Desciption |
diff --git a/thaw/src/image/image.css b/thaw/src/image/image.css
new file mode 100644
index 0000000..28efd3e
--- /dev/null
+++ b/thaw/src/image/image.css
@@ -0,0 +1,38 @@
+.thaw-image {
+ display: inline-block;
+ box-sizing: border-box;
+ border-color: var(--colorNeutralStroke1);
+ border-radius: var(--borderRadiusNone);
+}
+
+.thaw-image--rounded {
+ border-radius: var(--borderRadiusMedium);
+}
+
+.thaw-image--circular {
+ border-radius: var(--borderRadiusCircular);
+}
+
+.thaw-image--block {
+ width: 100%;
+}
+
+.thaw-image-fit-none {
+ object-fit: none;
+}
+.thaw-image-fit-contain {
+ object-fit: contain;
+}
+.thaw-image-fit-cover {
+ object-fit: cover;
+}
+.thaw-image-fit-fill {
+ object-fit: fill;
+}
+.thaw-image-fit-scale-down {
+ object-fit: scale-down;
+}
+
+.thaw-image--shadow {
+ box-shadow: var(--shadow4);
+}
diff --git a/thaw/src/image/mod.rs b/thaw/src/image/mod.rs
index 46eaa75..89ddf4b 100644
--- a/thaw/src/image/mod.rs
+++ b/thaw/src/image/mod.rs
@@ -1,44 +1,86 @@
use leptos::*;
-use thaw_utils::OptionalProp;
+use thaw_utils::{class_list, mount_style};
#[component]
pub fn Image(
- #[prop(optional, into)] src: OptionalProp>,
- #[prop(optional, into)] alt: OptionalProp>,
- #[prop(optional, into)] width: MaybeSignal,
- #[prop(optional, into)] height: MaybeSignal,
- #[prop(optional, into)] border_radius: MaybeSignal,
- #[prop(optional, into)] object_fit: OptionalProp>,
- #[prop(optional, into)] class: OptionalProp>,
+ /// path to the image you want to display
+ #[prop(optional, into)]
+ src: MaybeProp,
+ /// description of the image, which isn't mandatory but is incredibly useful for accessibility
+ #[prop(optional, into)]
+ alt: MaybeProp,
+ #[prop(optional, into)] width: MaybeProp,
+ #[prop(optional, into)] height: MaybeProp,
+ /// An image can appear square, circular, or rounded.
+ #[prop(optional, into)]
+ shape: MaybeSignal,
+ /// An image can set how it should be resized to fit its container.
+ #[prop(optional, into)]
+ block: MaybeSignal,
+ /// An image can appear elevated with shadow.
+ #[prop(optional, into)]
+ shadow: MaybeSignal,
+ /// An image can set how it should be resized to fit its container.
+ #[prop(optional, into)]
+ fit: MaybeSignal,
+ #[prop(optional, into)] class: MaybeProp,
) -> impl IntoView {
- let style = move || {
- let mut style = String::new();
-
- let width = width.get();
- if !width.is_empty() {
- style.push_str(&format!("width: {width};"))
- }
-
- let height = height.get();
- if !height.is_empty() {
- style.push_str(&format!("height: {height};"))
- }
-
- let border_radius = border_radius.get();
- if !border_radius.is_empty() {
- style.push_str(&format!("border-radius: {border_radius};"))
- }
-
- style
- };
+ mount_style("image", include_str!("./image.css"));
view! {
}
}
+
+#[derive(Default, Clone)]
+pub enum ImageShape {
+ Circular,
+ Rounded,
+ #[default]
+ Square,
+}
+
+impl ImageShape {
+ pub fn as_str(&self) -> &'static str {
+ match self {
+ ImageShape::Circular => "circular",
+ ImageShape::Rounded => "rounded",
+ ImageShape::Square => "square",
+ }
+ }
+}
+
+#[derive(Default, Clone)]
+pub enum ImageFit {
+ None,
+ Contain,
+ Cover,
+ #[default]
+ Fill,
+ ScaleDown,
+}
+
+impl ImageFit {
+ pub fn as_str(&self) -> &'static str {
+ match self {
+ ImageFit::None => "none",
+ ImageFit::Contain => "contain",
+ ImageFit::Cover => "cover",
+ ImageFit::Fill => "fill",
+ ImageFit::ScaleDown => "scale-down",
+ }
+ }
+}