Repository navigation
context layout
The LayoutContext manages UI state related to the application’s structural layout, including the expansion of the side navigation and the visibility of the header panel. It ensures that layout behavior is responsive and consistent across screen sizes, leveraging the useBreakpoint hook to adapt to Carbon Design System breakpoints.
This context is especially useful for controlling navigation and profile panel interactions without prop drilling. It provides a clean interface for toggling layout elements and reacting to screen size changes.
type LayoutContextType = {
isSideNavExpanded: boolean;
toggleSideNav: () => void;
isHeaderPanelOpen: boolean;
toggleHeaderPanel: () => void;
closeHeaderPanel: () => void;
};import { useLayout } from '@/context/layout/useLayout';
const HeaderMenuButton = () => {
const { isSideNavExpanded, toggleSideNav } = useLayout();
return (
<button onClick={toggleSideNav}>
{isSideNavExpanded ? 'Collapse Menu' : 'Expand Menu'}
</button>
);
};-
Responsive Behavior: Side nav is automatically collapsed on
'sm'and'md'breakpoints. -
State Management: Uses
useStatefor layout toggles anduseEffectto sync with breakpoints. - Encapsulation: All layout logic is centralized in the provider, keeping UI components clean.
<LayoutProvider>
<LayoutHeader />
<Content>
<Grid>{children}</Grid>
</Content>
</LayoutProvider>Wraps the layout shell and provides layout state to all nested components.
const { isSideNavExpanded, toggleSideNav } = useLayout();Ensures safe access to layout state and throws an error if used outside the provider.
This wiki documents NR Waste Plus for users and developers. Verify security and deployment guidance against the current application configuration before applying it elsewhere.
- Report an issue or ask a question in the GitHub repository.
- Follow the Contributing Guidelines to propose an update.
- Read the Code of Conduct.
Collection indexes support human browsing and machine retrieval. Keep both current when adding or moving wiki pages.
NR Waste Plus Wiki | GitHub Repository