@pablozaiden/webapp 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/web/WebAppRoot.tsx +15 -3
package/package.json
CHANGED
package/src/web/WebAppRoot.tsx
CHANGED
|
@@ -1002,16 +1002,28 @@ export function WebAppRoot({ appName, homeRoute, sidebar, routes, header, onRout
|
|
|
1002
1002
|
const headerTitle = header?.renderTitle?.(headerContext) ?? defaultTitle;
|
|
1003
1003
|
const primaryHeaderActions = header?.renderActions?.(headerContext);
|
|
1004
1004
|
const headerActionLabel = typeof headerTitle === "string" ? headerTitle : defaultTitle;
|
|
1005
|
+
const navigateFromSidebarHeader = (nextRoute: WebAppRoute) => {
|
|
1006
|
+
navigate(nextRoute);
|
|
1007
|
+
setSidebarOpen(false);
|
|
1008
|
+
};
|
|
1009
|
+
const runSidebarHeaderAction = (action: SidebarAction) => {
|
|
1010
|
+
if (action.onAction) {
|
|
1011
|
+
action.onAction();
|
|
1012
|
+
} else if (action.route) {
|
|
1013
|
+
navigate(action.route);
|
|
1014
|
+
}
|
|
1015
|
+
setSidebarOpen(false);
|
|
1016
|
+
};
|
|
1005
1017
|
|
|
1006
1018
|
return (
|
|
1007
1019
|
<main className={`wapp-shell ${sidebarCollapsed ? "sidebar-collapsed" : ""} ${sidebarOpen ? "sidebar-open" : ""}`}>
|
|
1008
1020
|
<div className="wapp-mobile-backdrop" onClick={() => setSidebarOpen(false)} />
|
|
1009
1021
|
<aside className="wapp-sidebar">
|
|
1010
1022
|
<div className="wapp-sidebar-header">
|
|
1011
|
-
<button type="button" className="wapp-brand" onClick={() =>
|
|
1023
|
+
<button type="button" className="wapp-brand" onClick={() => navigateFromSidebarHeader(homeRoute)}>{appName}</button>
|
|
1012
1024
|
<div className="wapp-sidebar-actions">
|
|
1013
|
-
{topActions.map((action) => <IconButton key={action.id} className="wapp-sidebar-top-button" title={action.title} aria-label={action.title} onClick={
|
|
1014
|
-
<IconButton className="wapp-sidebar-top-button" title="Settings" aria-label="Open settings" active={route.view === "settings"} onClick={() =>
|
|
1025
|
+
{topActions.map((action) => <IconButton key={action.id} className="wapp-sidebar-top-button" title={action.title} aria-label={action.title} onClick={() => runSidebarHeaderAction(action)}><ActionIcon icon={action.icon} /></IconButton>)}
|
|
1026
|
+
<IconButton className="wapp-sidebar-top-button" title="Settings" aria-label="Open settings" active={route.view === "settings"} onClick={() => navigateFromSidebarHeader({ view: "settings" })}><Icon name="settings" /></IconButton>
|
|
1015
1027
|
<IconButton className="wapp-sidebar-top-button" title="Collapse sidebar" aria-label="Collapse sidebar" onClick={() => { setSidebarCollapsed(true); setSidebarOpen(false); }}><Icon name="sidebar" /></IconButton>
|
|
1016
1028
|
</div>
|
|
1017
1029
|
</div>
|