This commit is contained in:
eraden 2022-05-11 16:13:58 +02:00
parent 316eab4883
commit 45ce1e89f6
3 changed files with 22 additions and 11 deletions

View File

@ -14,14 +14,21 @@ pub mod layout {
pub fn view<Msg>(
url: Url,
content: Node<Msg>,
categories: &[model::api::Category],
categories: Option<&[model::api::Category]>,
) -> 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![
C!["flex"],
div![
C!["flex flex-col w-64 h-screen px-4 py-8 overflow-y-auto border-r"],
super::sidebar::view(url, categories)
],
sidebar,
div![C!["w-full h-full p-4 m-8 overflow-y-auto"], content]
]
}

View File

@ -126,7 +126,7 @@ pub fn view(model: &crate::Model, page: &ListingPage) -> Node<crate::Msg> {
div![
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))
]
}

View File

@ -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 {
Msg::ProductFetched(Ok(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() {
None => return empty!(),
Some(product) => product,
@ -48,8 +48,8 @@ pub fn view(_model: &crate::Model, page: &ProductPage) -> Node<crate::Msg> {
.photos
.iter()
.enumerate()
.map(|(idx, img)| image(idx, img).map_msg(map_to_global));
div![
.map(|(idx, img)| image(idx, img));
let content = div![
C!["max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 mt-6"],
div![
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)
]
}