Skip to content

Commit c945363

Browse files
authored
docs: add development guide (#136)
1 parent c782fcd commit c945363

File tree

5 files changed

+71
-0
lines changed

5 files changed

+71
-0
lines changed

demo/src/app.rs

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ fn TheRouter(is_routing: RwSignal<bool>) -> impl IntoView {
3939
<Route path="/installation" view=InstallationMdPage/>
4040
<Route path="/usage" view=UsageMdPage/>
4141
<Route path="/server-sider-rendering" view=ServerSiderRenderingMdPage/>
42+
<Route path="/development/guide" view=DevelopmentGuideMdPage/>
43+
<Route path="/development/components" view=DevelopmentComponentsMdPage/>
4244
</Route>
4345
<Route path="/components" view=ComponentsPage>
4446
<Route path="/tabbar" view=TabbarPage/>

demo/src/pages/guide.rs

+13
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,18 @@ pub(crate) fn gen_guide_menu_data() -> Vec<MenuGroupOption> {
115115
label: "Server Sider Rendering".into(),
116116
}],
117117
},
118+
MenuGroupOption {
119+
label: "Development".into(),
120+
children: vec![
121+
MenuItemOption {
122+
value: "development/guide".into(),
123+
label: "Guide".into(),
124+
},
125+
MenuItemOption {
126+
value: "development/components".into(),
127+
label: "Components".into(),
128+
},
129+
],
130+
},
118131
]
119132
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Internal component
2+
3+
There are some internal components that let developers know how to use them.
4+
5+
## Binder / Follwer
6+
7+
```rust
8+
use crate::components::{Binder, Follower, FollowerPlacement};
9+
use leptos::*;
10+
11+
// Used to internally track the location of this DOM
12+
let div_ref= NodeRef::new();
13+
// Used to turn on and off the position to listen to the DOM when the show changes
14+
let show = RwSignal::new(false);
15+
16+
// placement: The position relative to the DOM when the popup opens
17+
18+
view! {
19+
<Binder target_ref=div_ref>
20+
<div ref=div_ref>
21+
"content"
22+
</div>
23+
<Follower slot show placement=FollowerPlacement::BottomStart>
24+
{
25+
move || {
26+
show.get().then_some("popover")
27+
}
28+
}
29+
</Follower>
30+
</Binder>
31+
}
32+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Development guide
2+
3+
### Code style
4+
5+
It is recommended to use the Rust style instead of the functional stule in the newly added reactive code.
6+
7+
```rust
8+
RwSignal::new(12) //
9+
create_rw_signal(12) // 🙅
10+
11+
Memo::new(|_| {}) //
12+
create_memo(|_| {}) // 🙅
13+
14+
Effect::new(|_| {}) //
15+
create_effect(|_| {}) // 🙅
16+
```

demo_markdown/src/lib.rs

+8
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@ use syn::ItemFn;
88
#[proc_macro]
99
pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
1010
let file_list = vec![
11+
(
12+
"DevelopmentComponentsMdPage",
13+
include_str!("../docs/_guide/development/components.md"),
14+
),
15+
(
16+
"DevelopmentGuideMdPage",
17+
include_str!("../docs/_guide/development/guide.md"),
18+
),
1119
(
1220
"InstallationMdPage",
1321
include_str!("../docs/_guide/installation.md"),

0 commit comments

Comments
 (0)