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
Observetoolbar is displayed at the top of the applicationObservetoolbar includes the following linksFull Stack TypescriptNavigates to the
/aboutview
AuthenticationOpens a menu of links
LoginNavigates to the
/loginview
Sign UpNavigates to the
/sign-upview
Forgot PasswordNavigates to the
/forgot-passwordview
Verify EmailNavigates to the
/verify-emailview
AccountNavigates to the
/accountview
GithubOpens a new window to the Github repository
Technical requirements
app-toolbarstandalone 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