14.177.1 • Published 13 hours ago

@genesislcap/foundation-header v14.177.1

Weekly downloads
-
License
SEE LICENSE IN li...
Repository
github
Last release
13 hours ago

Foundation-Header

API

Introduction

The Header micro front-end is a semi-batteries-included component. It consists of a navigation bar and flyout menu, with routing and account logout capabilities.

You can customise:

  • the icon shown on the navigation bar and flyout menu (this shows the Genesis logo by default)
  • navigation links at the left-hand side of the navigation bar
  • the control buttons on the right-hand side of the navigation bar; these can be shown or hidden, and their behaviour controlled via event listeners
  • The contents of the flyout menu

Here is an example of the navigation bar with three navigation items, and all three control buttons shown. Header with the standard genesis logo

This next example is the same as the previous example, except the Genesis logo is replaced with a custom icon. Header with a customised logo

In this next example, we have put a set of example options set in the flyout menu. The sidebar included with the header opened with some example content

Header set-up

Seed apps

A lot of the Genesis seed apps come with the Header set up by default. To verify, you can do a text search in the client code for the <foundation-header> tag. In this case, you only need to do the customisations described in customising the header.

:::tip The allRoutes array, which you need to change to set the navigation buttons on the Header, is found in client/web/src/routes/config.ts. :::

Manual set-up

To enable this micro front-end in your application, follow the steps below.

  • Add @genesislcap/foundation-header as a dependency in your package.json file. Whenever you change the dependencies of your project, ensure you run the bootstrap command again. There is more information in the package.json basics page.
{
  ...
  "dependencies": {
    "@genesislcap/foundation-header": "latest"
  },
  ...
}

:::note This page assumes you're already using the Login and Routing systems that are part of foundation-ui for the logout and routing functionality.

It is possible for you to set up routing manually, but that won't be covered in this tutorial. :::

  • In the top level class of your application, import and dependency inject the Navigation class.
import { Navigation } from '@genesislcap/foundation-header';

@customElement({ name, template, styles })
export class MainApplication extends FASTElement {
  @inject(MainRouterConfig) config!: MainRouterConfig;
  @inject(Navigation) navigation!: Navigation;

	...

}

:::tip If you haven't used the inject annotation in your application yet, you'll need to get it from the @microsoft/fast-foundation package. :::

  • Set a reference to the navigation object on the FAST router when you instantiate it; this will enable you to set up navigation functionality from the navigation bar in the navigation items step.
// fast-router will likely have other attributes such as :config too
const MainTemplate: ViewTemplate<MainApplication> = html`
  <fast-router :navigation=${(x) => x.navigation}></fast-router>
`;
  • Add the foundation-header tag as part of the html that you set as the markup for the defaultLayout in your router configuration.
export const defaultLayout = new FASTElementLayout(html`
<div class="container">
	<!-- show-luminance-toggle-button boolean attribute added to show that button on the navigation bar -->
	<foundation-header show-luminance-toggle-button></foundation-header>
	<!-- Other markup -->
</div>`);

export class MainRouterConfig extends RouterConfiguration<LoginSettings> {

	...

	public configure() {
		this.title = 'Example app';
		this.defaultLayout = defaultLayout;
		...
	}
}

Customising the header

Icon

By default, the navigation bar and flyout menu show the Genesis logo. You can override this by setting the logoSrc attribute. For example:

<foundation-header logoSrc="https://icotar.com/avatar/genesis"></foundation-header>

The logoSrc defines the image that you want to display. Adding this attribute will update the logo on both the flyout and navigation bar. Omit the attribute to leave the Genesis logo.

Navigation items

You can add navigation items can be added to the left-hand side of the navigation bar. For each element, you can set slot="routes" attribute, so that navigation is controlled via a @click event. The following is a really basic example for adding a 'Home' button:

html`
<foundation-header
	<zero-button
		slot="routes"
		value="1"
		@click=${(x, c) => c.parent.navigation.navigateTo("home")}
	>Home</zero-button>
></foundation-header>`;

The navigation object referenced via the parent object is why the navigation object is added as an attribute to the fast-router in the setup step. From it, the navigateTo method can be called, which allows the user to navigate around the finished application from the navigation buttons.

Moving on from this basic example, a dynamic set of routes can be configured, using the repeat directive from FAST.

  • Add the routes configuration into an array in the router configuration class.
export class MainRouterConfig extends RouterConfiguration<LoginSettings> {

	// New configuration added to existing MainRouterConfig class
	public allRoutes = [
		{ index: 1, path: 'protected', title: 'Home', icon: 'home', variant: 'solid' },
		{ index: 2, path: 'admin', title: 'Admin', icon: 'cog', variant: 'solid' },
		{ index: 3, path: 'reporting', title: 'Reporting', variant: 'solid' },
	];

	...
}
  • When setting the navigation items, use the repeat directive to iterate over the defined routes and create a navigation item for each.

The following example creates a button with an associated logo for each of the three defined routes:

html`
<foundation-header
    <div slot="routes">
        ${repeat(
            (x) => x.config.allRoutes,
            html`
                <zero-button
                    appearance="neutral-grey"
                    value="${(x) => x.index}"
                    @click=${(x, c) => c.parent.navigation.navigateTo(x.path)}
                >
                    <zero-icon variant="${(x) => x.variant}" name="${(x) => x.icon}"></zero-icon>
                    ${(x) => x.title}
                </zero-button>
            `
        )}
	</div>
></foundation-header>`;

Control buttons

There are three control buttons that can be shown or hidden on the right-hand side of the navigation bar (these are hidden by default). Each one of them is a boolean attribute that can be added where the <foundation-header> tag is defined. .

LogoToggle AttributeDispatched Event
Moonshow-luminance-toggle-buttonluminance-icon-clicked
Miscshow-misc-toggle-buttonmisc-icon-clicked
Notificationsshow-notification-buttonnotification-icon-clicked

Implementing the functionality of the buttons is up to the client. For example:

  • Define the functionality of the event callback in the class of a class which is a parent to the router.
export class MainApplication extends FASTElement {

	onMiscButtonPressed() {
		// ... do something
	}
	...
}
  • Set the event listener in the parent html to call the defined functionality.
// fast-router will likely have other attributes such as :config too
const MainTemplate: ViewTemplate<MainApplication> = html`
  <fast-router
		:navigation=${(x) => x.navigation}
		@misc-icon-clicked=${(x) => x.onMiscButtonPressed()}
	>
	</fast-router>
`;

Menu contents

To set the content of the flyout menu, add the content in the html within an element that has the slot="menu-contents" attribute.

<foundation-header>
	<div slot="menu-contents">
		<!-- Example markup -->
		<p>GROUP SLOT</p>
		<zero-tree-view>
			<zero-tree-item>
				<zero-icon name="location-arrow"></zero-icon>
				Slot Tree Item
			</zero-tree-item>
			<zero-tree-item>
				<zero-icon name="location-arrow"></zero-icon>
				Slot Tree Item
			</zero-tree-item>
		</zero-tree-view>
		<p>GROUP SLOT 2</p>
		<zero-tree-view>
			<zero-tree-item>
				<zero-icon name="location-arrow"></zero-icon>
				Slot Tree Item 2
			</zero-tree-item>
			<zero-tree-item>
				<zero-icon name="location-arrow"></zero-icon>
				Slot Tree Item 2
			</zero-tree-item>
		</zero-tree-view>
	</div>
</foundation-header>

License

Note: this project provides front end dependencies and uses licensed components listed in the next section, thus licenses for those components are required during development. Contact Genesis Global for more details.

14.177.1

19 hours ago

14.177.0

3 days ago

14.174.0

4 days ago

14.175.0

4 days ago

14.176.0

4 days ago

14.173.4

8 days ago

14.173.3

11 days ago

14.173.2

15 days ago

14.173.1

16 days ago

14.173.0

16 days ago

14.172.3

17 days ago

14.172.2

22 days ago

14.172.1

22 days ago

14.172.0

25 days ago

14.171.0

26 days ago

14.168.0

1 month ago

14.169.0

30 days ago

14.170.0

30 days ago

14.167.2

1 month ago

14.167.1

1 month ago

14.167.0

1 month ago

14.166.0

1 month ago

14.165.0

1 month ago

14.165.2

1 month ago

14.165.1

1 month ago

14.164.1

1 month ago

14.164.0

1 month ago

14.163.0

2 months ago

14.162.6

2 months ago

14.162.5

2 months ago

14.162.4

2 months ago

14.162.3

2 months ago

14.162.2

2 months ago

14.162.1

2 months ago

14.162.0

2 months ago

14.161.0

2 months ago

14.158.2

2 months ago

14.159.0

2 months ago

14.160.1

2 months ago

14.160.0

2 months ago

14.158.1

2 months ago

14.157.0

2 months ago

14.158.0

2 months ago

14.156.2

2 months ago

14.156.0

2 months ago

14.156.1

2 months ago

14.155.1

2 months ago

14.155.0

2 months ago

14.154.1

2 months ago

14.154.2

2 months ago

14.152.2

3 months ago

14.153.0

3 months ago

14.154.0

3 months ago

14.152.1

3 months ago

14.150.1

3 months ago

14.150.2

3 months ago

14.151.0

3 months ago

14.151.1

3 months ago

14.152.0

3 months ago

14.150.0

3 months ago

14.149.0

3 months ago

14.148.0

3 months ago

14.147.0

3 months ago

14.146.1

3 months ago

14.146.0

3 months ago

14.145.3

3 months ago

14.145.4

3 months ago

14.145.0

3 months ago

14.145.1

3 months ago

14.145.2

3 months ago

14.144.1

3 months ago

14.143.1

3 months ago

14.143.2

3 months ago

14.143.0

3 months ago

14.144.0

3 months ago

14.140.0

4 months ago

14.141.3

4 months ago

14.141.0

4 months ago

14.141.1

4 months ago

14.141.2

4 months ago

14.142.0

4 months ago

14.139.2

4 months ago

14.138.1

4 months ago

14.139.0

4 months ago

14.139.1

4 months ago

14.138.0

4 months ago

14.137.0

4 months ago

14.137.1

4 months ago

14.135.0

4 months ago

14.136.0

4 months ago

14.134.0

4 months ago

14.133.0

4 months ago

14.133.1

4 months ago

14.131.0

4 months ago

14.132.0

4 months ago

14.130.0

4 months ago

14.128.0

4 months ago

14.129.0

4 months ago

14.127.6

4 months ago

14.127.5

4 months ago

14.127.4

4 months ago

14.127.3

5 months ago

14.127.2

5 months ago

14.127.0

5 months ago

14.127.1

5 months ago

14.126.0-PA-1036.1

5 months ago

14.125.1

5 months ago

14.126.0

5 months ago

14.123.0

5 months ago

14.124.0

5 months ago

14.125.0

5 months ago

14.122.1

5 months ago

14.122.0

5 months ago

14.121.1

5 months ago

14.121.0

5 months ago

14.120.2

5 months ago

14.120.1

5 months ago

14.120.0

5 months ago

14.118.1

5 months ago

14.118.0

5 months ago

14.119.0

5 months ago

14.117.0

5 months ago

14.116.1

5 months ago

14.58.0

10 months ago

14.92.1-pa-913.3

7 months ago

14.92.1-pa-913.2

7 months ago

14.69.1

9 months ago

14.69.0

9 months ago

14.69.3

9 months ago

14.69.2

9 months ago

14.69.5

9 months ago

14.69.4

9 months ago

14.108.0

6 months ago

14.99.0-auth-mf.22

6 months ago

14.57.1

10 months ago

14.83.2-canary.1

7 months ago

14.57.0

10 months ago

14.68.2

9 months ago

14.68.1

9 months ago

14.109.0

6 months ago

14.68.0

9 months ago

14.90.0

7 months ago

14.59.0

10 months ago

14.78.0-mfa-auth.1

8 months ago

14.78.0-mfa-auth.8

8 months ago

14.78.0-mfa-auth.2

8 months ago

14.70.4-es2021.1

8 months ago

14.77.0

8 months ago

14.54.0

10 months ago

14.77.1

8 months ago

14.77.2

8 months ago

14.65.1

9 months ago

14.88.0

7 months ago

14.65.0

10 months ago

14.65.2

9 months ago

14.99.0

6 months ago

14.98.0-fui-1562.1

6 months ago

14.53.0

10 months ago

14.94.0-pa-957.1

7 months ago

14.76.0

8 months ago

14.64.0

10 months ago

14.87.0

7 months ago

14.64.2

10 months ago

14.64.1

10 months ago

14.64.3

10 months ago

14.79.1

8 months ago

14.110.0

6 months ago

14.79.0

8 months ago

14.56.0

10 months ago

14.67.3

9 months ago

14.67.2

9 months ago

14.67.5

9 months ago

14.67.4

9 months ago

14.67.1

9 months ago

14.67.0

9 months ago

14.78.2

8 months ago

14.78.3

8 months ago

14.111.0

6 months ago

14.55.0

10 months ago

14.78.0

8 months ago

14.78.1

8 months ago

14.66.0

9 months ago

14.89.0

7 months ago

14.96.1

6 months ago

14.96.0

6 months ago

14.112.0

6 months ago

14.50.1

11 months ago

14.73.0

8 months ago

14.50.0

11 months ago

14.50.3

10 months ago

14.50.2

11 months ago

14.50.5

10 months ago

14.50.4

10 months ago

14.50.6

10 months ago

14.100.0

6 months ago

14.100.1

6 months ago

14.61.1

10 months ago

14.84.0

7 months ago

14.61.0

10 months ago

14.84.1

7 months ago

14.61.2

10 months ago

14.95.0

6 months ago

14.113.1

6 months ago

14.113.0

6 months ago

14.71.1-auth-mf.2

8 months ago

14.71.1-auth-mf.4

8 months ago

14.71.1-auth-mf.3

8 months ago

14.72.0

8 months ago

14.71.1-auth-mf.6

8 months ago

14.71.1-auth-mf.9

8 months ago

14.101.1

6 months ago

14.101.2

6 months ago

14.101.0

6 months ago

14.101.3

6 months ago

14.60.0

10 months ago

14.101.4

6 months ago

14.83.0

8 months ago

14.83.1

8 months ago

14.83.2

7 months ago

14.83.3

7 months ago

14.83.4

7 months ago

14.83.5

7 months ago

14.83.6

7 months ago

14.83.7

7 months ago

14.98.0

6 months ago

14.92.0-pa-913.1

7 months ago

14.114.0

6 months ago

14.114.2

5 months ago

14.114.1

6 months ago

14.52.1

10 months ago

14.75.0

8 months ago

14.52.0

10 months ago

14.52.2

10 months ago

14.102.0

6 months ago

14.94.1-pa-958.1

6 months ago

14.63.1

10 months ago

14.86.0

7 months ago

14.63.0

10 months ago

14.97.0

6 months ago

14.115.1

5 months ago

14.115.0

5 months ago

14.51.0

10 months ago

14.74.0

8 months ago

14.103.0

6 months ago

14.62.0

10 months ago

14.85.0

7 months ago

14.62.1

10 months ago

14.92.5

7 months ago

14.49.0-bny.2

10 months ago

14.92.4

7 months ago

14.92.3

7 months ago

14.92.2

7 months ago

14.49.0-bny.1

10 months ago

14.92.1

7 months ago

14.92.0

7 months ago

14.116.0

5 months ago

14.80.0

8 months ago

14.104.0

6 months ago

14.91.3

7 months ago

14.91.2

7 months ago

14.91.1

7 months ago

14.91.0

7 months ago

14.71.1-auth-mf.20

7 months ago

14.71.1-auth-mf.21

7 months ago

14.70.4-test.1

8 months ago

14.71.1-auth-mf.11

7 months ago

14.71.1-auth-mf.10

7 months ago

14.71.1-auth-mf.13

7 months ago

14.105.0

6 months ago

14.71.1-auth-mf.12

7 months ago

14.71.1-auth-mf.15

7 months ago

14.71.1-auth-mf.14

7 months ago

14.71.1-auth-mf.17

7 months ago

14.71.1-auth-mf.16

7 months ago

14.71.1-auth-mf.19

7 months ago

14.71.1-auth-mf.18

7 months ago

14.94.2

6 months ago

14.94.1

7 months ago

14.94.0

7 months ago

14.71.0

8 months ago

14.71.1

8 months ago

14.71.2

8 months ago

14.94.0-pa-899.1

6 months ago

14.106.0

6 months ago

14.106.1

6 months ago

14.82.0

8 months ago

14.93.0

7 months ago

14.70.0

9 months ago

14.70.1

9 months ago

14.70.2

8 months ago

14.70.3

8 months ago

14.70.4

8 months ago

14.70.5

8 months ago

14.70.6

8 months ago

14.70.7

8 months ago

14.70.8

8 months ago

14.107.1

6 months ago

14.107.0

6 months ago

14.81.0

8 months ago

14.46.0

11 months ago

14.45.0

11 months ago

14.48.0

11 months ago

14.47.0

11 months ago

14.41.2-bny.5

11 months ago

14.41.2-bny.4

11 months ago

14.49.1

11 months ago

14.49.0

11 months ago

14.44.0

11 months ago

14.35.0

11 months ago

14.34.0

11 months ago

14.30.2-bny.9

11 months ago

14.30.2-bny.8

11 months ago

14.30.2-bny.7

11 months ago

14.37.0

11 months ago

14.30.2-bny.6

11 months ago

14.30.2-bny.5

11 months ago

14.30.2-bny.4

11 months ago

14.30.2-bny.3

11 months ago

14.30.2-bny.2

11 months ago

14.30.2-bny.1

11 months ago

14.40.1

11 months ago

14.40.0

11 months ago

14.36.0

11 months ago

14.41.2-bny.1

11 months ago

14.30.1-bny.1

11 months ago

14.41.2-bny.3

11 months ago

14.41.2-bny.2

11 months ago

14.39.0

11 months ago

14.31.0

11 months ago

14.42.0

11 months ago

14.42.1

11 months ago

14.38.0

11 months ago

14.30.0

11 months ago

14.30.1

11 months ago

14.30.2

11 months ago

14.30.3

11 months ago

14.25.0-bny.4

11 months ago

14.25.0-bny.3

11 months ago

14.41.0

11 months ago

14.41.1

11 months ago

14.41.2

11 months ago

14.33.1

11 months ago

14.33.2

11 months ago

14.33.0

11 months ago

14.29.2

11 months ago

14.29.1

11 months ago

14.32.0

11 months ago

14.32.1

11 months ago

14.43.0

11 months ago

14.43.1

11 months ago

14.25.0-bny.2

11 months ago

14.12.5

1 year ago

14.16.0

1 year ago

14.12.4

1 year ago

14.12.3

1 year ago

14.12.2

1 year ago

14.12.6

1 year ago

14.12.1

1 year ago

14.12.0

1 year ago

14.9.0

1 year ago

14.27.0

11 months ago

14.27.1

11 months ago

14.23.0

12 months ago

14.15.2

1 year ago

14.15.1

1 year ago

14.15.0

1 year ago

14.11.3

1 year ago

14.19.0

12 months ago

14.11.2

1 year ago

14.11.1

1 year ago

14.11.0

1 year ago

14.26.1

12 months ago

14.26.2

12 months ago

14.26.0

12 months ago

14.26.5

12 months ago

14.26.6

11 months ago

14.25.0-bny.1

12 months ago

14.26.3

12 months ago

14.26.4

12 months ago

14.26.7

11 months ago

14.22.1

12 months ago

14.22.0

12 months ago

14.14.0

1 year ago

14.18.0

12 months ago

14.24.3-bny.21

12 months ago

14.10.0

1 year ago

14.25.0

12 months ago

14.29.0

11 months ago

14.11.0-bny.15

1 year ago

14.11.0-bny.17

1 year ago

14.11.0-bny.16

1 year ago

14.21.0

12 months ago

14.20.0-bny.19

12 months ago

14.17.0

12 months ago

14.15.1-bny.18

1 year ago

14.8.0-bny.14

1 year ago

14.8.0-bny.13

1 year ago

14.8.0-bny.12

1 year ago

14.24.4-bny.22

12 months ago

14.20.0-bny.20

12 months ago

14.24.4-bny.25

12 months ago

14.24.4-bny.24

12 months ago

14.24.4-bny.23

12 months ago

14.13.0

1 year ago

14.26.5-canary.1

11 months ago

14.24.3

12 months ago

14.28.0

11 months ago

14.24.4

12 months ago

14.24.1

12 months ago

14.24.2

12 months ago

14.20.0

12 months ago

14.24.0

12 months ago

14.20.1

12 months ago

13.7.0

1 year ago

13.5.0

1 year ago

13.3.0

1 year ago

14.1.0

1 year ago

13.1.0

1 year ago

14.3.0

1 year ago

14.5.0

1 year ago

14.7.0

1 year ago

12.0.0

1 year ago

12.0.1

1 year ago

12.0.2

1 year ago

11.4.2

1 year ago

11.4.3

1 year ago

11.4.0

1 year ago

11.4.1

1 year ago

14.7.0-bny.10

1 year ago

11.4.0-bny.6

1 year ago

11.4.0-bny.7

1 year ago

13.8.0

1 year ago

13.6.0

1 year ago

13.4.0

1 year ago

13.2.0-pa-659.2

1 year ago

13.4.1

1 year ago

13.2.0-pa-659.1

1 year ago

13.2.0

1 year ago

14.0.0

1 year ago

14.0.1

1 year ago

13.0.0

1 year ago

14.2.0

1 year ago

13.0.1

1 year ago

14.4.0

1 year ago

14.6.0

1 year ago

14.6.1

1 year ago

14.8.0

1 year ago

14.8.0-bny.11

1 year ago

11.3.1

1 year ago

11.4.3-bny.8

1 year ago

11.4.3-bny.7

1 year ago

11.3.0

1 year ago

11.4.3-bny.9

1 year ago

10.3.1

1 year ago

10.3.0

1 year ago