Repository navigation
LayoutHeaderGlobalBar
The LayoutHeaderGlobalBar component provides global action buttons in the application header, including theme toggle and user profile access with contextual district/client display.
This component does not accept any props. It manages its own state through context hooks.
import LayoutHeaderGlobalBar from '@/components/Layout/LayoutHeader/LayoutHeaderGlobalBar';
// Typically used within LayoutHeader
<Header>
<LayoutHeaderGlobalBar />
</Header>- Theme Toggle: Switch between light and dark modes
- User Profile: Access user settings and preferences with avatar display
The component displays different information based on the user's identity provider:
-
BCeID Business Users (
BCEIDBUSINESS): Shows ClientDisplay - IDIR Users: Shows DistrictDisplay
Displays a small avatar with user initials extracted from first and last name.
<HeaderGlobalBar>
<HeaderGlobalAction> {/* Theme */}
<ThemeToggle />
</HeaderGlobalAction>
<HeaderGlobalAction> {/* Profile */}
<AvatarImage />
{user?.idpProvider === 'BCEIDBUSINESS' ? (
<ClientDisplay />
) : (
<DistrictDisplay />
)}
</HeaderGlobalAction>
</HeaderGlobalBar>const { toggleHeaderPanel, isHeaderPanelOpen } = useLayout();-
toggleHeaderPanel: Opens/closes the user profile panel -
isHeaderPanelOpen: Boolean indicating panel state
const { user } = useAuth();Accesses user information including:
- First name
- Last name
- Identity provider type
The user profile button includes:
- User avatar with initials
- Selected client/district name (if applicable)
- Chevron icon indicating panel state
- Click to toggle profile panel
- Active state styling when panel is open
- Tooltip alignment: end
{user?.idpProvider === 'BCEIDBUSINESS' ? (
<ClientDisplay isActive={isHeaderPanelOpen} />
) : (
<DistrictDisplay isActive={isHeaderPanelOpen} />
)}.profile-action-button {
width: fit-content;
max-width: none;
color: white;
padding: 0.75rem;
margin-left: 0.5rem;
display: flex;
gap: 0.5rem;
}&.header__action--active {
color: var(--layer-selected-inverse);
}.header__global {
button.header__action {
border-radius: 0;
}
button.header__action--active {
background: var(--layer-02);
border: 0;
}
}- Default text color:
colors.$white - Active color:
--layer-selected-inverse - Background (active):
--layer-02 - Icon fill: currentColor
- Theme action:
aria-label="Theme" - Profile action:
aria-label="User settings"
Both actions use tooltipAlignment="end" for consistent positioning.
- Proper focus states for keyboard navigation
- No outline on focus (handled by Carbon)
- LayoutProvider: For panel state management
- AuthProvider: For user information
- ThemeProvider: For theme toggle functionality
- PreferenceProvider: For client/district preferences
- ThemeToggle: Theme switching control
- AvatarImage: User avatar display
- ClientDisplay: Business client information
- DistrictDisplay: District information
-
HeaderGlobalBar: Container for global actions -
HeaderGlobalAction: Individual action button wrapper
Shows client selection for business users:
user?.idpProvider === 'BCEIDBUSINESS'Shows district selection for government users:
// All non-BCeID users default to DistrictDisplayimport { Header, HeaderGlobalBar, HeaderGlobalAction } from '@carbon/react';
import { LayoutProvider } from '@/context/layout/LayoutProvider';
import { AuthProvider } from '@/context/auth/AuthProvider';
import LayoutHeaderGlobalBar from '@/components/Layout/LayoutHeader/LayoutHeaderGlobalBar';
function AppHeader() {
return (
<AuthProvider>
<LayoutProvider>
<Header>
{/* Other header elements */}
<LayoutHeaderGlobalBar />
</Header>
</LayoutProvider>
</AuthProvider>
);
}- LayoutHeader: Parent header component
- ThemeToggle: Theme switching control
- AvatarImage: User avatar display
- ClientDisplay: Client selection display
- DistrictDisplay: District selection display
- LayoutHeaderPanel: Profile panel that opens on click
- Context Order: Ensure AuthProvider wraps LayoutProvider
- Single Instance: Use only one global bar per header
- Consistent Placement: Keep in the same position across all pages
- Accessibility: Maintain ARIA labels and keyboard support
- User clicks theme icon
- Theme switches immediately
- Preference persists across sessions
- User clicks profile button
- Panel slides in from right
- Shows user info and preferences
- Click outside or close button to dismiss
- The component adapts based on user identity provider
- Profile button shows different information for different user types
- All state is managed through context providers
- Follows BC Government design patterns
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