mirror of
https://github.com/adoyle0/thaw.git
synced 2025-01-22 22:09:22 -05:00
feat(lepots-v0.7): demo Home page
This commit is contained in:
parent
48b62a4d07
commit
74be938fbc
7 changed files with 46 additions and 50 deletions
|
@ -30,19 +30,18 @@ pub fn App() -> impl IntoView {
|
|||
|
||||
#[component]
|
||||
fn TheRouter(is_routing: RwSignal<bool>) -> impl IntoView {
|
||||
let loading_bar = use_loading_bar();
|
||||
_ = is_routing.watch(move |is_routing| {
|
||||
if *is_routing {
|
||||
loading_bar.start();
|
||||
} else {
|
||||
loading_bar.finish();
|
||||
}
|
||||
});
|
||||
// let loading_bar = use_loading_bar();
|
||||
// _ = is_routing.watch(move |is_routing| {
|
||||
// if *is_routing {
|
||||
// loading_bar.start();
|
||||
// } else {
|
||||
// loading_bar.finish();
|
||||
// }
|
||||
// });
|
||||
|
||||
view! {
|
||||
<Routes fallback=|| "404">
|
||||
<Route path=StaticSegment("") view=Home/>
|
||||
<Route path=StaticSegment("/home") view=Home/>
|
||||
// <Route path="/guide" view=ComponentsPage>
|
||||
// <Route path="/installation" view=InstallationMdPage/>
|
||||
// <Route path="/usage" view=UsageMdPage/>
|
||||
|
@ -114,9 +113,11 @@ fn TheProvider(children: Children) -> impl IntoView {
|
|||
|
||||
view! {
|
||||
<ConfigProvider>
|
||||
<ToasterProvider>
|
||||
<LoadingBarProvider>{children()}</LoadingBarProvider>
|
||||
</ToasterProvider>
|
||||
// <ToasterProvider>
|
||||
// <LoadingBarProvider>
|
||||
{children()}
|
||||
// </LoadingBarProvider>
|
||||
// </ToasterProvider>
|
||||
</ConfigProvider>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ mod button_group;
|
|||
pub use button_group::ButtonGroup;
|
||||
|
||||
use crate::icon::Icon;
|
||||
use leptos::{ev, prelude::*};
|
||||
use leptos::{either::Either, ev, prelude::*};
|
||||
use send_wrapper::SendWrapper;
|
||||
use thaw_components::OptionComp;
|
||||
use thaw_utils::{class_list, mount_style, OptionalMaybeSignal, OptionalProp};
|
||||
|
@ -122,9 +122,13 @@ pub fn Button(
|
|||
}
|
||||
}
|
||||
}
|
||||
<OptionComp value=children let:children>
|
||||
{children()}
|
||||
</OptionComp>
|
||||
{
|
||||
if let Some(children) = children {
|
||||
Either::Left(children())
|
||||
} else {
|
||||
Either::Right(())
|
||||
}
|
||||
}
|
||||
</button>
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,15 +1,9 @@
|
|||
use leptos::prelude::*;
|
||||
use thaw_utils::{class_list, OptionalProp};
|
||||
|
||||
#[component]
|
||||
pub fn LayoutHeader(
|
||||
#[prop(optional, into)] class: OptionalProp<MaybeSignal<String>>,
|
||||
children: Children,
|
||||
) -> impl IntoView {
|
||||
pub fn LayoutHeader(children: Children) -> impl IntoView {
|
||||
view! {
|
||||
<div
|
||||
class=class_list!["thaw-layout-header", class.map(| c | move || c.get())]
|
||||
>
|
||||
<div class="thaw-layout-header">
|
||||
{children()}
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -1,19 +1,16 @@
|
|||
use crate::Scrollbar;
|
||||
use leptos::prelude::*;
|
||||
use thaw_utils::{class_list, mount_style, OptionalProp};
|
||||
use thaw_utils::{mount_style, OptionalProp};
|
||||
|
||||
#[component]
|
||||
pub fn LayoutSider(
|
||||
#[prop(optional, into)] class: OptionalProp<MaybeSignal<String>>,
|
||||
#[prop(optional, into)] content_class: OptionalProp<MaybeSignal<String>>,
|
||||
#[prop(optional, into)] content_style: OptionalProp<MaybeSignal<String>>,
|
||||
children: Children,
|
||||
) -> impl IntoView {
|
||||
mount_style("layout-sider", include_str!("./layout-sider.css"));
|
||||
view! {
|
||||
<div
|
||||
class=class_list!["thaw-layout-sider", class.map(| c | move || c.get())]
|
||||
>
|
||||
<div class="thaw-layout-sider">
|
||||
<Scrollbar content_class content_style>
|
||||
{children()}
|
||||
</Scrollbar>
|
||||
|
|
|
@ -6,7 +6,7 @@ pub use layout_sider::*;
|
|||
|
||||
use crate::Scrollbar;
|
||||
use leptos::prelude::*;
|
||||
use thaw_utils::{class_list, mount_style, OptionalProp};
|
||||
use thaw_utils::{mount_style, OptionalProp};
|
||||
|
||||
#[derive(Default, PartialEq)]
|
||||
pub enum LayoutPosition {
|
||||
|
@ -26,7 +26,6 @@ impl LayoutPosition {
|
|||
|
||||
#[component]
|
||||
pub fn Layout(
|
||||
#[prop(optional, into)] class: OptionalProp<MaybeSignal<String>>,
|
||||
#[prop(optional, into)] content_class: OptionalProp<MaybeSignal<String>>,
|
||||
#[prop(optional, into)] content_style: OptionalProp<MaybeSignal<String>>,
|
||||
#[prop(optional)] position: LayoutPosition,
|
||||
|
@ -43,9 +42,7 @@ pub fn Layout(
|
|||
}
|
||||
});
|
||||
view! {
|
||||
<div
|
||||
class=class_list![gen_class(position), class.map(| c | move || c.get())]
|
||||
>
|
||||
<div class=gen_class(position)>
|
||||
<Scrollbar
|
||||
content_class
|
||||
content_style=Signal::derive(move || {
|
||||
|
|
|
@ -135,14 +135,19 @@ pub fn Scrollbar(
|
|||
sync_scroll_state();
|
||||
};
|
||||
let on_mouseleave = move |_| {
|
||||
thumb_status.update_value(|thumb_status| {
|
||||
if thumb_status.is_some() {
|
||||
*thumb_status = Some(ThumbStatus::DelayLeave);
|
||||
} else {
|
||||
is_show_y_thumb.set(false);
|
||||
is_show_x_thumb.set(false);
|
||||
}
|
||||
});
|
||||
if Some(true)
|
||||
== thumb_status.try_update_value(|thumb_status| {
|
||||
if thumb_status.is_some() {
|
||||
*thumb_status = Some(ThumbStatus::DelayLeave);
|
||||
false
|
||||
} else {
|
||||
true
|
||||
}
|
||||
})
|
||||
{
|
||||
is_show_y_thumb.set(false);
|
||||
is_show_x_thumb.set(false);
|
||||
}
|
||||
};
|
||||
|
||||
let on_scroll = move |_| {
|
||||
|
|
|
@ -145,7 +145,7 @@ where
|
|||
R: DomRenderer,
|
||||
{
|
||||
type AsyncOutput = Self;
|
||||
type State = (R::ClassList, String);
|
||||
type State = (R::Element, String);
|
||||
type Cloneable = Self;
|
||||
type CloneableOwned = Self;
|
||||
|
||||
|
@ -178,26 +178,24 @@ where
|
|||
if !FROM_SERVER {
|
||||
R::add_class(&class_list, &class);
|
||||
}
|
||||
(class_list, class)
|
||||
(el.clone(), class)
|
||||
}
|
||||
|
||||
fn build(self, el: &R::Element) -> Self::State {
|
||||
let class_list = R::class_list(el);
|
||||
let mut class = String::new();
|
||||
self.to_class_string(&mut class);
|
||||
if !class.is_empty() {
|
||||
R::add_class(&class_list, &class);
|
||||
R::set_attribute(el, "class", &class);
|
||||
}
|
||||
(class_list, class)
|
||||
(el.clone(), class)
|
||||
}
|
||||
|
||||
fn rebuild(self, state: &mut Self::State) {
|
||||
let mut class = String::new();
|
||||
self.to_class_string(&mut class);
|
||||
let (class_list, prev_class) = state;
|
||||
let (el, prev_class) = state;
|
||||
if class != *prev_class {
|
||||
R::remove_class(class_list, prev_class);
|
||||
R::add_class(class_list, &class);
|
||||
R::set_attribute(el, "class", &class);
|
||||
}
|
||||
*prev_class = class;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue