Skip to content

Commit d3ad858

Browse files
authored
Merge pull request #2 from opensass/dioxus
feat: add dioxus support && add direction prop
2 parents c896638 + 81214bd commit d3ad858

File tree

18 files changed

+3310
-60
lines changed

18 files changed

+3310
-60
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ leptos = { version = "0.8.0", optional = true }
2121
web-sys = { version = "0.3.77", features = [
2222
"Document",
2323
"Window",
24+
"HtmlHeadElement",
2425
"IntersectionObserver",
2526
"IntersectionObserverInit",
2627
"IntersectionObserverEntry",

DIOXUS.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# 🧬 Skeleton RS Dioxus Usage
2+
3+
Adding Skeleton RS to your project is simple:
4+
5+
1. Make sure your project is set up with **Dioxus**. Refer to the [Dioxus Getting Started Guide](https://dioxuslabs.com/learn/0.6/getting_started) for setup instructions.
6+
7+
1. Add the **skeleton-rs** library to your dependencies by including it in your `Cargo.toml` file:
8+
9+
```sh
10+
cargo add skeleton-rs --features=dio
11+
```
12+
13+
1. Import the `Skeleton` component into your Dioxus application.
14+
15+
## 🛠️ Usage
16+
17+
Incorporating Skeleton RS into your **Dioxus** application is straightforward. Follow these steps:
18+
19+
1. Import the `Skeleton` component into your Dioxus project:
20+
21+
```rust
22+
use dioxus::prelude::*;
23+
use skeleton_rs::dioxus::Skeleton;
24+
use skeleton_rs::{Variant, Animation, Direction, Theme};
25+
```
26+
27+
1. Use the `Skeleton` component within your Dioxus application:
28+
29+
```rust
30+
use dioxus::prelude::*;
31+
use skeleton_rs::dioxus::Skeleton;
32+
use skeleton_rs::Variant;
33+
34+
#[component]
35+
fn App() -> Element {
36+
rsx! {
37+
Skeleton {
38+
variant: Variant::Text,
39+
width: "100%",
40+
height: "1.2em",
41+
}
42+
}
43+
}
44+
```
45+
46+
## 🔧 Props
47+
48+
| Property | Type | Description | Default |
49+
| ------------ | ----------- | ---------------------------------------------------------------------- | ------------- |
50+
| `variant` | `Variant` | Visual variant: `Text`, `Circle`, `Rect`, etc. | `Text` |
51+
| `animation` | `Animation` | Animation style: `Pulse`, `Wave`, `None`. | `Pulse` |
52+
| `direction` | `Direction` | Animation direction: `LeftToRight`, `RightToLeft`, `TopToBottom`, etc. | `LeftToRight` |
53+
| `theme` | `Theme` | Theme for light/dark variants. | `Light` |
54+
| `show` | `bool` | Manually control visibility of the skeleton. | `false` |
55+
| `delay_ms` | `u32` | Delay before showing the skeleton in milliseconds. | `0` |
56+
| `infer_size` | `bool` | Infers width/height from child content if true. | `false` |
57+
| `responsive` | `bool` | Enables scaling for responsive layouts. | `false` |
58+
| `children` | `Element` | Content to wrap in skeleton loading. | `None` |
59+
60+
### 🎨 Styling Props
61+
62+
| Property | Type | Description | Default |
63+
| --------------- | -------------- | ---------------------------------- | -------- |
64+
| `width` | `&'static str` | Width of the skeleton block. | `"100%"` |
65+
| `height` | `&'static str` | Height of the skeleton block. | `"1em"` |
66+
| `font_size` | `Option<&str>` | Font size used for text variant. | `None` |
67+
| `border_radius` | `&'static str` | Border radius for rounded shapes. | `"4px"` |
68+
| `line_height` | `&'static str` | Line height of the skeleton block. | `"1"` |
69+
| `margin` | `&'static str` | External margin styling. | `""` |
70+
| `custom_style` | `&'static str` | Inline custom styles. | `""` |
71+
72+
### ⚙️ Visibility Behavior
73+
74+
| Property | Type | Description | Default |
75+
| -------------------- | ------ | ------------------------------------------------------------ | ------- |
76+
| `animate_on_hover` | `bool` | Starts animation on hover. | `false` |
77+
| `animate_on_focus` | `bool` | Starts animation on focus. | `false` |
78+
| `animate_on_active` | `bool` | Starts animation on active interaction (e.g., click). | `false` |
79+
| `animate_on_visible` | `bool` | Uses IntersectionObserver to trigger animation when in view. | `false` |
80+
81+
### 📏 Layout Constraints
82+
83+
| Property | Type | Description | Default |
84+
| ------------ | -------------- | --------------------------- | ------- |
85+
| `max_width` | `Option<&str>` | Max width of the skeleton. | `None` |
86+
| `min_width` | `Option<&str>` | Min width of the skeleton. | `None` |
87+
| `max_height` | `Option<&str>` | Max height of the skeleton. | `None` |
88+
| `min_height` | `Option<&str>` | Min height of the skeleton. | `None` |
89+
90+
## 💡 Notes
91+
92+
- The `Skeleton` component is ideal for loading states and placeholder UIs.
93+
- When `animate_on_visible` is enabled, `IntersectionObserver` is used to optimize performance.
94+
- Use the `show` prop to manually toggle visibility or let the component manage it.
95+
- Enable `infer_size` to make the skeleton size itself based on wrapped children.
96+
- For improved UX, use `delay_ms` to avoid flashing placeholders for fast-loading content.
97+
- Customize styles with `custom_style` and regular class/style props.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
| Framework | Live Demo |
2222
| --- | --- |
2323
| Yew | [![Netlify Status](https://api.netlify.com/api/v1/badges/a0efc7e9-f20e-4dd9-93e1-c8f4fde7506f/deploy-status)](https://skeleton-rs.netlify.app) |
24-
| Dioxus | TODO |
24+
| Dioxus | [![Netlify Status](https://api.netlify.com/api/v1/badges/a0efc7e9-f20e-4dd9-93e1-c8f4fde7506f/deploy-status)](https://skeleton-dio.netlify.app) |
2525
| Leptos | TODO |
2626

2727
## 📜 Intro
@@ -43,7 +43,7 @@ The following features make Skeleton RS an essential building block for modern f
4343
<!-- absolute url for docs.rs cause YEW.md is not included in crate -->
4444
Refer to [our guide](https://github.com/opensass/skeleton-rs/blob/main/YEW.md) to integrate this component into your Yew app.
4545

46-
## 🧬 Dioxus Usage (TODO)
46+
## 🧬 Dioxus Usage
4747

4848
<!-- absolute url for docs.rs cause DIOXUS.md is not included in crate -->
4949
Refer to [our guide](https://github.com/opensass/skeleton-rs/blob/main/DIOXUS.md) to integrate this component into your Dioxus app.

YEW.md

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,17 @@ Incorporating Skeleton RS into your Yew application is easy. Follow these steps:
4747

4848
## 🔧 Props
4949

50-
### 🧱 Main Props
51-
52-
| Property | Type | Description | Default |
53-
| ------------ | ----------- | -------------------------------------------------- | ------- |
54-
| `variant` | `Variant` | Visual variant: `Text`, `Circle`, `Rect`, etc. | `Text` |
55-
| `animation` | `Animation` | Animation style: `Pulse`, `Wave`, `None`. | `Pulse` |
56-
| `theme` | `Theme` | Theme for light/dark variants. | `Light` |
57-
| `show` | `bool` | Manually control visibility of the skeleton. | `false` |
58-
| `delay_ms` | `u32` | Delay before showing the skeleton in milliseconds. | `0` |
59-
| `infer_size` | `bool` | Infers width/height from child content if true. | `false` |
60-
| `responsive` | `bool` | Enables scaling for responsive layouts. | `false` |
61-
| `children` | `Html` | Content to wrap in skeleton loading. | `None` |
50+
| Property | Type | Description | Default |
51+
| ------------ | ----------- | ---------------------------------------------------------------------- | ------------- |
52+
| `variant` | `Variant` | Visual variant: `Text`, `Circle`, `Rect`, etc. | `Text` |
53+
| `animation` | `Animation` | Animation style: `Pulse`, `Wave`, `None`. | `Pulse` |
54+
| `direction` | `Direction` | Animation direction: `LeftToRight`, `RightToLeft`, `TopToBottom`, etc. | `LeftToRight` |
55+
| `theme` | `Theme` | Theme for light/dark variants. | `Light` |
56+
| `show` | `bool` | Manually control visibility of the skeleton. | `false` |
57+
| `delay_ms` | `u32` | Delay before showing the skeleton in milliseconds. | `0` |
58+
| `infer_size` | `bool` | Infers width/height from child content if true. | `false` |
59+
| `responsive` | `bool` | Enables scaling for responsive layouts. | `false` |
60+
| `children` | `Html` | Content to wrap in skeleton loading. | `None` |
6261

6362
### 🎨 Styling Props
6463

0 commit comments

Comments
 (0)