Application Toolbar component example

The following is a walkthrough of creating the AppToolbarComponent component

Example change request

Overview

The application toolbar will provide users with the ability to navigate the application.

Acceptance criteria

  • Observe toolbar is displayed at the top of the application

  • Observe toolbar includes the following links

    • Full Stack Typescript

      • Navigates to the /about view

    • Authentication

      • Opens a menu of links

      • Login

        • Navigates to the /login view

      • Sign Up

        • Navigates to the /sign-up view

      • Forgot Password

        • Navigates to the /forgot-password view

      • Verify Email

        • Navigates to the /verify-email view

      • Account

        • Navigates to the /account view

    • Github

      • Opens a new window to the Github repository

Technical requirements

  • app-toolbar standalone component

Generate component library

Run the below command to generate the app-toolbar component library.

The following project files should be created:

Rename the component files to be app-toolbar.component.ts|html|scss

Update app-toolbar.component.ts to be:

Update libs\components\app-toolbar\src\index.ts to export the app-toolbar component.

We are now ready to begin development on the app-toolbar in effort to satisfy the change request acceptance criteria.

Update AppToolbarComponent files

Update AppToolbarComponent

The AppToolbarComponent will need its imports update to satisfy the change request requirements.

Update libs\components\app-toolbar\src\lib\app-toolbar.component.ts to be:

Update AppToolbarComponent template

Update libs\components\app-toolbar\src\lib\app-toolbar.component.html to be:

Update AppToolbarComponent styles

Often, a design is a provided to guide the development of the component styles. However, for this example we will add some simple styles for our toolbar.

Update libs\components\app-toolbar\src\lib\app-toolbar.component.scss to be:

Update main application

Now that our AppToolbarComponent is ready for use, we can import it in the main application.

Update AppModule

Update apps\full-stack-typescript\src\app\app.module.ts to include the new component.

Update AppComponent template

Update apps\full-stack-typescript\src\app\app.component.html to include the new toolbar component.

Update AppComponent styles

Update apps\full-stack-typescript\src\app\app.component.scss to include some simple toolbar styles.

Conclusion

Our new component should now be available for use. Serve the application and verify everything is working properly.

nx serve full-stack-typescript

Last updated