Sidebar
This commit is contained in:
parent
316eab4883
commit
45ce1e89f6
@ -14,14 +14,21 @@ pub mod layout {
|
|||||||
pub fn view<Msg>(
|
pub fn view<Msg>(
|
||||||
url: Url,
|
url: Url,
|
||||||
content: Node<Msg>,
|
content: Node<Msg>,
|
||||||
categories: &[model::api::Category],
|
categories: Option<&[model::api::Category]>,
|
||||||
) -> Node<Msg> {
|
) -> Node<Msg> {
|
||||||
|
let sidebar = match categories {
|
||||||
|
Some(categories) => {
|
||||||
|
let sidebar = super::sidebar::view(url, categories);
|
||||||
|
div![
|
||||||
|
C!["flex flex-col w-64 h-screen px-4 py-8 overflow-y-auto border-r"],
|
||||||
|
sidebar
|
||||||
|
]
|
||||||
|
}
|
||||||
|
_ => empty![],
|
||||||
|
};
|
||||||
div![
|
div![
|
||||||
C!["flex"],
|
C!["flex"],
|
||||||
div![
|
sidebar,
|
||||||
C!["flex flex-col w-64 h-screen px-4 py-8 overflow-y-auto border-r"],
|
|
||||||
super::sidebar::view(url, categories)
|
|
||||||
],
|
|
||||||
div![C!["w-full h-full p-4 m-8 overflow-y-auto"], content]
|
div![C!["w-full h-full p-4 m-8 overflow-y-auto"], content]
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ pub fn view(model: &crate::Model, page: &ListingPage) -> Node<crate::Msg> {
|
|||||||
|
|
||||||
div![
|
div![
|
||||||
crate::shared::view::public_navbar(model),
|
crate::shared::view::public_navbar(model),
|
||||||
super::layout::view(page.url.clone(), content, &page.categories)
|
super::layout::view(model.url.clone(), content, Some(&page.categories))
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,9 +26,9 @@ pub fn init(mut url: Url, orders: &mut impl Orders<Msg>) -> ProductPage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn page_changed(url: Url, model: &mut ProductPage) {}
|
pub fn page_changed(_url: Url, _model: &mut ProductPage) {}
|
||||||
|
|
||||||
pub fn update(msg: Msg, model: &mut ProductPage, orders: &mut impl Orders<Msg>) {
|
pub fn update(msg: Msg, model: &mut ProductPage, _orders: &mut impl Orders<Msg>) {
|
||||||
match msg {
|
match msg {
|
||||||
Msg::ProductFetched(Ok(product)) => {
|
Msg::ProductFetched(Ok(product)) => {
|
||||||
model.product = Some(product);
|
model.product = Some(product);
|
||||||
@ -39,7 +39,7 @@ pub fn update(msg: Msg, model: &mut ProductPage, orders: &mut impl Orders<Msg>)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn view(_model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
|
pub fn view(model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
|
||||||
let product = match page.product.as_ref() {
|
let product = match page.product.as_ref() {
|
||||||
None => return empty!(),
|
None => return empty!(),
|
||||||
Some(product) => product,
|
Some(product) => product,
|
||||||
@ -48,8 +48,8 @@ pub fn view(_model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
|
|||||||
.photos
|
.photos
|
||||||
.iter()
|
.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(|(idx, img)| image(idx, img).map_msg(map_to_global));
|
.map(|(idx, img)| image(idx, img));
|
||||||
div![
|
let content = div![
|
||||||
C!["max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mt-6"],
|
C!["max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mt-6"],
|
||||||
div![
|
div![
|
||||||
C!["flex flex-col md:flex-row -mx-4"],
|
C!["flex flex-col md:flex-row -mx-4"],
|
||||||
@ -68,6 +68,10 @@ pub fn view(_model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
|
|||||||
]
|
]
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
].map_msg(map_to_global);
|
||||||
|
div![
|
||||||
|
crate::shared::view::public_navbar(model),
|
||||||
|
super::layout::view(model.url.clone(), content, None)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user