2023-12-11 17:05:35 +08:00
|
|
|
import React from 'react';
|
|
|
|
import {useShopStore} from "./shop_store";
|
2023-11-30 17:26:17 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Component that provides a base layout (aside/main) for the page.
|
|
|
|
*/
|
|
|
|
|
2023-12-11 17:05:35 +08:00
|
|
|
|
|
|
|
export function Layout({aside, main}) {
|
2023-12-13 15:17:14 +08:00
|
|
|
const {mobileSideMenuShouldOpen, onClickToggleMobileSideMenu, showCardAddedFeedback} = useShopStore((state) => ({
|
|
|
|
mobileSideMenuShouldOpen: state.sideMenuIsOpen,
|
|
|
|
onClickToggleMobileSideMenu: state.switchSideMenu,
|
|
|
|
showCardAddedFeedback: state.showCardAddedFeedback,
|
|
|
|
isMobile: state.isMobile,
|
|
|
|
}));
|
2023-12-11 17:05:35 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div className="layout">
|
|
|
|
|
|
|
|
<aside className={'aside ' + (mobileSideMenuShouldOpen ? 'menu-opened' : '')}>{aside}</aside>
|
|
|
|
|
|
|
|
{mobileSideMenuShouldOpen ? (
|
|
|
|
<section className="main" onClick={onClickToggleMobileSideMenu}>{main}</section>
|
|
|
|
) : (
|
|
|
|
<section className="main">{main}</section>
|
|
|
|
)}
|
|
|
|
|
2023-12-13 15:17:14 +08:00
|
|
|
{showCardAddedFeedback ? (
|
2023-12-11 17:05:35 +08:00
|
|
|
<div className="feedback-add-success">
|
|
|
|
✓ added
|
|
|
|
</div>
|
|
|
|
) : null}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|