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