Foundation Header
foundation-header is a micro front-end consisting of a navigation bar and a flyout menu, with routing, account-logout capabilities, and the ability to change the current language.
It supports nested navigation permissions and layout item active indicators for route nav items.
The navigation bar reflects the current route: the active top-level item (and nested child row, when applicable) receives selected styling based on pathname polling. To detect whether a nav item should appear active in custom templates, use hasActiveChild. You can change the highlight with the --foundation-header-selected-item-background design token: pick any colour you want, or remove the highlight by matching the normal button fill or using transparent where appropriate; see Selected route highlight colour in Customizing the header.
Adding a header component to the template
Here is an example of a simple navigation bar with two navigation items. This header does not show additional control buttons but displays the default ones, allowing for showing submenus, the logged-in user's name, and the connection status.
- React
- Genesis
- Angular
Declaration:
<foundation-header></foundation-header>
Usage:
@customElement({
name: 'header-example',
template: html`
<foundation-header
:routeNavItems=${(x) => x.navItems}
></foundation-header>
`,
})
export class HeaderExample extends GenesisElement {
const navItems = [{
title: "Home",
icon: {
name: "home",
variant: "solid",
},
navId: "header",
placementIndex: 0,
routePath: "home",
routeName: "home",
},
{
title: "Grids",
icon: {
name: "table",
variant: "solid",
},
navId: "header",
placementIndex: 1,
routePath: "grids",
routeName: "grids",
}];
}
Declaration:
<FoundationHeader></FoundationHeader>
Usage:
import { FoundationHeader } from '@genesislcap/foundation-header/react';
export default function HeaderExample({}) {
const navItems = [{
title: "Home",
icon: {
name: "home",
variant: "solid",
},
navId: "header",
placementIndex: 0,
routePath: "home",
routeName: "home",
},
{
title: "Grids",
icon: {
name: "table",
variant: "solid",
},
navId: "header",
placementIndex: 1,
routePath: "grids",
routeName: "grids",
}];
return (
<FoundationHeader
routeNavItems={navItems}
></FoundationHeader>
);
}
Declaration:
<foundation-header></foundation-header>
Usage
import { Component, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
@Component({
selector: 'header-example',
template: `
<foundation-header
[routeNavItems]="navItems"
></foundation-header>
`,
standalone: true,
schemas: [CUSTOM_ELEMENTS_SCHEMA],
})
export class HeaderExampleComponent {
navItems = [{
title: "Home",
icon: {
name: "home",
variant: "solid",
},
navId: "header",
placementIndex: 0,
routePath: "home",
routeName: "home",
},
{
title: "Grids",
icon: {
name: "table",
variant: "solid",
},
navId: "header",
placementIndex: 1,
routePath: "grids",
routeName: "grids",
}];
}
Attributes
| Attribute | Type | Use | Example |
|---|---|---|---|
| logo-src | string | Optional attribute which sets the source of the image in the navigation bar and flyout menu. The Genesis logo will be shown if this attribute is not provided. | |
| logo-alt-text | string | Optional attribute which controls the alt text of the logo. If this attribute is not set then the alt text is set to 'Corporate Logo'. | |
| show-luminance-toggle-button | boolean | Boolean attribute which controls whether the navigation bar will display the luminance toggle icon. | |
| show-misc-toggle-button | boolean | Boolean attribute which controls whether the navigation bar will display the miscellaneous behaviour icon. | |
| show-notification-button | boolean | Boolean attribute which controls whether the navigation bar will display the show notification icon. | |
| show-connection-indicator | boolean | Boolean attribute which controls whether the navigation bar will display the connection indicator. | |
| show-environment-indicator | boolean | Boolean attribute which controls whether the navigation bar will display the environment indicator. See Environment Indicator for configuration details. | |
| show-language-selector | boolean | Boolean attribute which controls whether the navigation bar will display the language selector. | |
| hide-side-bar | boolean | Boolean attribute which controls whether the navigation bar will display the side bar. | |
| enable-inactivity-monitoring | boolean | Boolean attribute which controls whether client side inactivity monitoring is enabled. - Defaults to true | |
| inactivity-timeout-minutes | string | Attribute which controls the duration of inactivity within the app before the inactivity warning dialog is shown to the user. Requires enable-inactivity-monitoring - Defaults to 30 | |
| inactivity-warning-minutes | string | Attribute which controls the duration that the warning dialog is shown to the user, before the user is logged out. Requires enable-inactivity-monitoring - Defaults to 5 | |
Properties
| Property | Type | Use | Example |
|---|---|---|---|
| userName | string | Username of the logged in user. | |
| languageOptions | LanguageOptions | Object which defines the language options to be displayed in the language selector. | |
| routeNavItems | FoundationRouteNavItem[] | Array of FoundationRouteNavItems which define the route buttons to be displayed in the navigation bar, including nested submenu items. Permission checks apply to nested items as well as top-level items. | |
| layoutItemCheck | (registration: string) => boolean | (BETA) Callback used to determine if a layout nav item is currently active. Works with nav items that set isLayoutItem and layoutRegistration. | |
Slots
| Slot Name | Description |
|---|---|
| menu-contents | Slot for adding custom content to the flyout menu (side navigation). |
| routes | Slot for adding custom route buttons to the navigation bar. |
| routes-end | Slot for adding custom route buttons to the end of the navigation bar. |
Parts
| Part Name | Description |
|---|---|
| dynamic-template | The element representing the dynamic template content. |
Methods
| Method Name | Description |
|---|---|
| logout | Logs the user out of their session. |
| navigateTo | Changes the route of the current page. |
Fired Events
| Event Name | Type | Description | Example |
|---|---|---|---|
| luminance-icon-clicked | void | Dispatched when the user clicks on the luminance toggle icon in the navigation bar. | |
| misc-icon-clicked | void | Dispatched when the user clicks on the miscellaneous behaviour icon in the navigation bar. | |
| notification-icon-clicked | void | Dispatched when the user clicks on the notification icon in the navigation bar. | |
| language-changed | void | Dispatched when the user changes the language in the language selector. | |
| logout-clicked | void | Dispatched when the user clicks logout button. | |
For a full list of attributes and properties, see API documents.