mirror of
https://github.com/adoyle0/thaw.git
synced 2025-02-02 16:44:15 -05:00
✨ feat: add layout-sider component
This commit is contained in:
parent
7c2c87a6d6
commit
0296c4a00b
8 changed files with 83 additions and 29 deletions
3
gh-pages/src/components/mod.rs
Normal file
3
gh-pages/src/components/mod.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
mod site_header;
|
||||||
|
|
||||||
|
pub use site_header::*;
|
24
gh-pages/src/components/site_header.rs
Normal file
24
gh-pages/src/components/site_header.rs
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
use leptos::*;
|
||||||
|
use leptos_router::use_navigate;
|
||||||
|
use melt_ui::*;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn SiteHeader(cx: Scope) -> impl IntoView {
|
||||||
|
view! { cx,
|
||||||
|
<LayoutHeader
|
||||||
|
style="height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid #efeff6"
|
||||||
|
>
|
||||||
|
<span style="cursor: pointer" on:click=move |_| {
|
||||||
|
let navigate = use_navigate(cx);
|
||||||
|
_ = navigate("/", Default::default());
|
||||||
|
}>
|
||||||
|
"Melt UI"
|
||||||
|
</span>
|
||||||
|
<Button type_=ButtonType::TEXT on:click=move |_| {
|
||||||
|
_ = window().open_with_url("http://github.com/luoxiaozero/melt-ui");
|
||||||
|
}>
|
||||||
|
"Github"
|
||||||
|
</Button>
|
||||||
|
</LayoutHeader>
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,5 @@
|
||||||
mod app;
|
mod app;
|
||||||
|
mod components;
|
||||||
mod pages;
|
mod pages;
|
||||||
|
|
||||||
use app::*;
|
use app::*;
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::components::SiteHeader;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_router::{use_location, use_navigate, Outlet};
|
use leptos_router::{use_location, use_navigate, Outlet};
|
||||||
use melt_ui::*;
|
use melt_ui::*;
|
||||||
|
@ -30,8 +31,10 @@ pub fn ComponentsPage(cx: Scope) -> impl IntoView {
|
||||||
selected
|
selected
|
||||||
});
|
});
|
||||||
view! {cx,
|
view! {cx,
|
||||||
<div class="components-page-box">
|
<Layout position=LayoutPosition::ABSOLUTE>
|
||||||
<aside>
|
<SiteHeader />
|
||||||
|
<Layout has_sider=true position=LayoutPosition::ABSOLUTE style="top: 54px;">
|
||||||
|
<LayoutSider>
|
||||||
<Menu selected>
|
<Menu selected>
|
||||||
<MenuItem key="menu" label="menu" />
|
<MenuItem key="menu" label="menu" />
|
||||||
<MenuItem key="slider" label="slider" />
|
<MenuItem key="slider" label="slider" />
|
||||||
|
@ -44,10 +47,11 @@ pub fn ComponentsPage(cx: Scope) -> impl IntoView {
|
||||||
<MenuItem key="checkbox" label="checkbox" />
|
<MenuItem key="checkbox" label="checkbox" />
|
||||||
<MenuItem key="toast" label="toast" />
|
<MenuItem key="toast" label="toast" />
|
||||||
</Menu>
|
</Menu>
|
||||||
</aside>
|
</LayoutSider>
|
||||||
<main>
|
<Layout>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</Layout>
|
||||||
</div>
|
</Layout>
|
||||||
|
</Layout>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use crate::components::*;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use leptos_router::{use_navigate, use_query_map};
|
use leptos_router::{use_navigate, use_query_map};
|
||||||
use melt_ui::*;
|
use melt_ui::*;
|
||||||
|
@ -14,16 +15,7 @@ pub fn Home(cx: Scope) -> impl IntoView {
|
||||||
}
|
}
|
||||||
view! { cx,
|
view! { cx,
|
||||||
<Layout position=LayoutPosition::ABSOLUTE>
|
<Layout position=LayoutPosition::ABSOLUTE>
|
||||||
<LayoutHeader
|
<SiteHeader />
|
||||||
style="height: 54px; display: flex; align-items: center; justify-content: space-between; padding: 0 20px; border-bottom: 1px solid #efeff6"
|
|
||||||
>
|
|
||||||
"Melt UI"
|
|
||||||
<Button type_=ButtonType::TEXT on:click=move |_| {
|
|
||||||
_ = window().open_with_url("http://github.com/luoxiaozero/melt-ui");
|
|
||||||
}>
|
|
||||||
"Github"
|
|
||||||
</Button>
|
|
||||||
</LayoutHeader>
|
|
||||||
<Layout position=LayoutPosition::ABSOLUTE style="top: 54px; display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
<Layout position=LayoutPosition::ABSOLUTE style="top: 54px; display: flex; align-items: center; justify-content: center; flex-direction: column;">
|
||||||
<p>"A Leptos UI Library"</p>
|
<p>"A Leptos UI Library"</p>
|
||||||
<Button on:click=move |_| {
|
<Button on:click=move |_| {
|
||||||
|
|
4
src/layout/layout-sider.css
Normal file
4
src/layout/layout-sider.css
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
.melt-layout-sider {
|
||||||
|
position: relative;
|
||||||
|
min-width: 260px;
|
||||||
|
}
|
15
src/layout/layout_sider.rs
Normal file
15
src/layout/layout_sider.rs
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
use crate::utils::mount_style::mount_style;
|
||||||
|
use leptos::*;
|
||||||
|
use stylers::style_sheet_str;
|
||||||
|
|
||||||
|
#[component]
|
||||||
|
pub fn LayoutSider(cx: Scope, children: Children) -> impl IntoView {
|
||||||
|
let class_name = mount_style("layout-sider", || {
|
||||||
|
style_sheet_str!("./src/layout/layout-sider.css")
|
||||||
|
});
|
||||||
|
view! { cx, class=class_name,
|
||||||
|
<div class="melt-layout-sider">
|
||||||
|
{ children(cx) }
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,9 @@
|
||||||
mod layout_header;
|
mod layout_header;
|
||||||
|
mod layout_sider;
|
||||||
|
|
||||||
use crate::utils::mount_style::mount_style;
|
use crate::utils::mount_style::mount_style;
|
||||||
pub use layout_header::*;
|
pub use layout_header::*;
|
||||||
|
pub use layout_sider::*;
|
||||||
use leptos::*;
|
use leptos::*;
|
||||||
use stylers::style_sheet_str;
|
use stylers::style_sheet_str;
|
||||||
|
|
||||||
|
@ -26,9 +28,18 @@ pub fn Layout(
|
||||||
cx: Scope,
|
cx: Scope,
|
||||||
#[prop(optional, into)] style: MaybeSignal<String>,
|
#[prop(optional, into)] style: MaybeSignal<String>,
|
||||||
#[prop(optional)] position: LayoutPosition,
|
#[prop(optional)] position: LayoutPosition,
|
||||||
|
#[prop(optional, into)] has_sider: MaybeSignal<bool>,
|
||||||
children: Children,
|
children: Children,
|
||||||
) -> impl IntoView {
|
) -> impl IntoView {
|
||||||
let class_name = mount_style("layout", || style_sheet_str!("./src/layout/layout.css"));
|
let class_name = mount_style("layout", || style_sheet_str!("./src/layout/layout.css"));
|
||||||
|
|
||||||
|
let style = create_memo(cx, move |_| {
|
||||||
|
let mut style = style.get();
|
||||||
|
if has_sider.get() {
|
||||||
|
style.push_str("display: flex; flex-wrap: nowrap; flex-direction: row; width: 100;%")
|
||||||
|
}
|
||||||
|
style
|
||||||
|
});
|
||||||
view! { cx, class=class_name,
|
view! { cx, class=class_name,
|
||||||
<div class="melt-layout" class=("melt-layout--absolute-positioned", position == LayoutPosition::ABSOLUTE) style=move || style.get()>
|
<div class="melt-layout" class=("melt-layout--absolute-positioned", position == LayoutPosition::ABSOLUTE) style=move || style.get()>
|
||||||
{ children(cx) }
|
{ children(cx) }
|
||||||
|
|
Loading…
Add table
Reference in a new issue