11 Project: Website menu

 

This chapter covers

  • Creating the necessary scaffolding for a menu component
  • Rendering a static website menu
  • Homework: Adding advanced features to the menu

We’ve reached a milestone. With the completion of chapter 10, you now know all you need to know about React itself to start building some pretty complex web applications. This and the next two chapters are all project chapters. These projects are much larger examples that guide you through the first steps of creating a full-featured web application and set you up for creating more advanced variants of those same applications.

The project in this chapter is a website menu. It’s a top-bar menu component that you can directly use in a website. We’ll create this project in five steps, as outlined in figure 11.1.

Figure 11.1 We start this project with a scaffold, and through the steps in this chapter, we’ll build a fully fledged dynamic menu with an optional link to a profile page.
11-01

The scaffold is where you start out building this application. Each additional step of the application adds more advanced features to the menu while utilizing new parts of the React API. We’ll set up step 1 first in this chapter, and then we’ll solve step 2 together. From then on, we’ll introduce the subsequent steps to you, but then you have to solve them yourself.

11.1 Scaffolding for the menu

11.1.1 HTML output

11.1.2 Component hierarchy

11.1.3 Icons

11.1.4 CSS

11.1.5 Template

11.1.6 Source code

11.1.7 In the browser

11.2 Rendering a static menu

11.2.1 The goal of this exercise

11.2.2 Desired HTML output

11.2.3 Component tree

11.2.4 Source code