docs: add development guide (#136)

This commit is contained in:
luoxiaozero 2024-03-14 20:16:09 +08:00 committed by GitHub
parent c782fcd853
commit c945363168
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 71 additions and 0 deletions

View file

@ -39,6 +39,8 @@ fn TheRouter(is_routing: RwSignal<bool>) -> impl IntoView {
<Route path="/installation" view=InstallationMdPage/>
<Route path="/usage" view=UsageMdPage/>
<Route path="/server-sider-rendering" view=ServerSiderRenderingMdPage/>
<Route path="/development/guide" view=DevelopmentGuideMdPage/>
<Route path="/development/components" view=DevelopmentComponentsMdPage/>
</Route>
<Route path="/components" view=ComponentsPage>
<Route path="/tabbar" view=TabbarPage/>

View file

@ -115,5 +115,18 @@ pub(crate) fn gen_guide_menu_data() -> Vec<MenuGroupOption> {
label: "Server Sider Rendering".into(),
}],
},
MenuGroupOption {
label: "Development".into(),
children: vec![
MenuItemOption {
value: "development/guide".into(),
label: "Guide".into(),
},
MenuItemOption {
value: "development/components".into(),
label: "Components".into(),
},
],
},
]
}

View file

@ -0,0 +1,32 @@
# Internal component
There are some internal components that let developers know how to use them.
## Binder / Follwer
```rust
use crate::components::{Binder, Follower, FollowerPlacement};
use leptos::*;
// Used to internally track the location of this DOM
let div_ref= NodeRef::new();
// Used to turn on and off the position to listen to the DOM when the show changes
let show = RwSignal::new(false);
// placement: The position relative to the DOM when the popup opens
view! {
<Binder target_ref=div_ref>
<div ref=div_ref>
"content"
</div>
<Follower slot show placement=FollowerPlacement::BottomStart>
{
move || {
show.get().then_some("popover")
}
}
</Follower>
</Binder>
}
```

View file

@ -0,0 +1,16 @@
# Development guide
### Code style
It is recommended to use the Rust style instead of the functional stule in the newly added reactive code.
```rust
RwSignal::new(12) // ✅
create_rw_signal(12) // 🙅
Memo::new(|_| {}) // ✅
create_memo(|_| {}) // 🙅
Effect::new(|_| {}) // ✅
create_effect(|_| {}) // 🙅
```

View file

@ -8,6 +8,14 @@ use syn::ItemFn;
#[proc_macro]
pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
let file_list = vec![
(
"DevelopmentComponentsMdPage",
include_str!("../docs/_guide/development/components.md"),
),
(
"DevelopmentGuideMdPage",
include_str!("../docs/_guide/development/guide.md"),
),
(
"InstallationMdPage",
include_str!("../docs/_guide/installation.md"),