mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-22 22:09:22 -05:00
refactor: dead code
This commit is contained in:
parent
e86d273502
commit
4086a57e3b
9 changed files with 43 additions and 138 deletions
|
@ -44,9 +44,7 @@ fn TheRouter(is_routing: RwSignal<bool>) -> impl IntoView {
|
|||
<Route path=StaticSegment("") view=Home/>
|
||||
<ParentRoute path=StaticSegment("guide") view=ComponentsPage>
|
||||
<Route path=StaticSegment("installation") view=InstallationMdPage/>
|
||||
<Route path=StaticSegment("usage") view=UsageMdPage/>
|
||||
<Route path=StaticSegment("server-sider-rendering") view=ServerSiderRenderingMdPage/>
|
||||
<Route path=(StaticSegment("development"), StaticSegment("guide")) view=DevelopmentGuideMdPage/>
|
||||
<Route path=(StaticSegment("development"), StaticSegment("components")) view=DevelopmentComponentsMdPage/>
|
||||
</ParentRoute>
|
||||
<ParentRoute path=StaticSegment("components") view=ComponentsPage>
|
||||
|
|
|
@ -105,31 +105,20 @@ pub(crate) fn gen_menu_data() -> Vec<MenuGroupOption> {
|
|||
label: "Installation".into(),
|
||||
},
|
||||
MenuItemOption {
|
||||
value: "/guide/usage".into(),
|
||||
label: "Usage".into(),
|
||||
},
|
||||
],
|
||||
},
|
||||
MenuGroupOption {
|
||||
label: "Guides".into(),
|
||||
children: vec![MenuItemOption {
|
||||
value: "/guide/server-sider-rendering".into(),
|
||||
label: "Server Sider Rendering".into(),
|
||||
}],
|
||||
},
|
||||
MenuGroupOption {
|
||||
label: "Development".into(),
|
||||
children: vec![
|
||||
MenuItemOption {
|
||||
value: "/guide/development/guide".into(),
|
||||
label: "Guide".into(),
|
||||
},
|
||||
MenuItemOption {
|
||||
value: "/guide/development/components".into(),
|
||||
label: "Components".into(),
|
||||
},
|
||||
],
|
||||
},
|
||||
// MenuGroupOption {
|
||||
// label: "Development".into(),
|
||||
// children: vec![
|
||||
// MenuItemOption {
|
||||
// value: "/guide/development/components".into(),
|
||||
// label: "Components".into(),
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
MenuGroupOption {
|
||||
label: "Components".into(),
|
||||
children: vec![
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
# Development guide
|
||||
|
||||
### Code style
|
||||
|
||||
It is recommended to use the Rust style instead of the functional style in the newly added reactive code.
|
||||
|
||||
```rust
|
||||
RwSignal::new(12) // ✅
|
||||
create_rw_signal(12) // 🙅
|
||||
|
||||
Memo::new(|_| {}) // ✅
|
||||
create_memo(|_| {}) // 🙅
|
||||
|
||||
Effect::new(|_| {}) // ✅
|
||||
create_effect(|_| {}) // 🙅
|
||||
```
|
|
@ -1,7 +1,38 @@
|
|||
# Installation
|
||||
## Installation
|
||||
|
||||
Installation thaw
|
||||
|
||||
```shell
|
||||
cargo add thaw --features=csr
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
You just need to import thaw and use it.
|
||||
|
||||
```rust
|
||||
// Import all
|
||||
use thaw::*;
|
||||
// Import on Demand
|
||||
use thaw::{Button, ButtonAppearance};
|
||||
```
|
||||
|
||||
A small example:
|
||||
|
||||
```rust
|
||||
use leptos::prelude::*;
|
||||
use thaw::*;
|
||||
|
||||
fn main() {
|
||||
mount_to_body(App);
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
view! {
|
||||
<Button appearance=ButtonAppearance::Primary>
|
||||
"Primary"
|
||||
</Button>
|
||||
}
|
||||
}
|
||||
```
|
|
@ -1,28 +0,0 @@
|
|||
# Usage
|
||||
|
||||
You just need to import thaw and use it.
|
||||
|
||||
```rust
|
||||
// Import all
|
||||
use thaw::*;
|
||||
// Import on Demand
|
||||
use thaw::{Button, ButtonVariant};
|
||||
```
|
||||
|
||||
A small example:
|
||||
|
||||
```rust
|
||||
use leptos::*;
|
||||
use thaw::*;
|
||||
|
||||
fn main() {
|
||||
mount_to_body(App);
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn App() -> impl IntoView {
|
||||
view! {
|
||||
<Button variant=ButtonVariant::Primary>"Primary"</Button>
|
||||
}
|
||||
}
|
||||
```
|
|
@ -21,10 +21,8 @@ macro_rules! file_path {
|
|||
pub fn include_md(_token_stream: proc_macro::TokenStream) -> proc_macro::TokenStream {
|
||||
let file_list = file_path! {
|
||||
"DevelopmentComponentsMdPage" => "../docs/_guide/development/components.md",
|
||||
"DevelopmentGuideMdPage" => "../docs/_guide/development/guide.md",
|
||||
"InstallationMdPage" => "../docs/_guide/installation.md",
|
||||
"ServerSiderRenderingMdPage" => "../docs/_guide/server_sider_rendering.md",
|
||||
"UsageMdPage" => "../docs/_guide/usage.md",
|
||||
// "NavBarMdPage" => "../docs/_mobile/nav_bar/mod.md",
|
||||
// "TabbarMdPage" => "../docs/_mobile/tabbar/mod.md",
|
||||
// "ToastMdPage" => "../docs/_mobile/toast/mod.md",
|
||||
|
|
|
@ -4,7 +4,6 @@ mod focus_trap;
|
|||
mod if_comp;
|
||||
mod option_comp;
|
||||
mod teleport;
|
||||
mod wave;
|
||||
|
||||
pub use binder::{Binder, Follower, FollowerPlacement, FollowerWidth};
|
||||
pub use css_transition::CSSTransition;
|
||||
|
@ -12,7 +11,6 @@ pub use focus_trap::FocusTrap;
|
|||
pub use if_comp::{ElseIf, If, Then};
|
||||
pub use option_comp::OptionComp;
|
||||
pub use teleport::Teleport;
|
||||
pub use wave::{Wave, WaveRef};
|
||||
|
||||
use leptos::prelude::{slot, ChildrenFn};
|
||||
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
use leptos::{html, leptos_dom::helpers::TimeoutHandle, prelude::*};
|
||||
use std::time::Duration;
|
||||
use thaw_utils::{mount_style, ComponentRef};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct WaveRef {
|
||||
play: Callback<()>,
|
||||
}
|
||||
|
||||
impl WaveRef {
|
||||
pub fn play(&self) {
|
||||
self.play.call(());
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
pub fn Wave(#[prop(optional)] comp_ref: ComponentRef<WaveRef>) -> impl IntoView {
|
||||
mount_style("wave", include_str!("./wave.css"));
|
||||
let wave_ref = NodeRef::<html::Div>::new();
|
||||
let animation_timeout_handle = RwSignal::new(None::<TimeoutHandle>);
|
||||
let play = Callback::new(move |_: ()| {
|
||||
if let Some(handle) = animation_timeout_handle.get() {
|
||||
handle.clear();
|
||||
animation_timeout_handle.set(None);
|
||||
}
|
||||
if let Some(wave_ref) = wave_ref.get() {
|
||||
_ = wave_ref.offset_height();
|
||||
}
|
||||
let handle = set_timeout_with_handle(
|
||||
move || {
|
||||
animation_timeout_handle.set(None);
|
||||
},
|
||||
Duration::from_secs(1),
|
||||
);
|
||||
if let Ok(handle) = handle {
|
||||
animation_timeout_handle.set(Some(handle))
|
||||
}
|
||||
});
|
||||
comp_ref.load(WaveRef { play });
|
||||
on_cleanup(move || {
|
||||
if let Some(handle) = animation_timeout_handle.get() {
|
||||
handle.clear();
|
||||
animation_timeout_handle.set(None);
|
||||
}
|
||||
});
|
||||
view! {
|
||||
<div
|
||||
class="thaw-wave"
|
||||
class=(
|
||||
"thaw-wave--active",
|
||||
move || animation_timeout_handle.with(|handle| handle.is_some()),
|
||||
)
|
||||
|
||||
node_ref=wave_ref
|
||||
></div>
|
||||
}
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
.thaw-wave {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
border-radius: inherit;
|
||||
}
|
Loading…
Add table
Reference in a new issue