Exercises
Both of the exercises on this page use the same project:
Screensaver
Remember in the 90s, it was common for TVs to have "bouncy logo" screensavers?
In this exercise, we're going to revive it!
Inside /src/app/exercises/01-screensaver
, you'll find a <ScreenSaver>
component. The bouncing-around logic has already been implemented. Your mission is to allow the user to change the color using routing:
Acceptance Criteria:
- When the user visits a route like
/exercises/01-screensaver/hotpink
, a<ScreenSaver>
component should be rendered using the color specified (hotpink
). - The
/exercises/01-screensaver
route should be updated so that it includes a list of links, so that users can choose a color. Feel free to pick your favourite named HTML colors (opens in new tab)! - All 147 named colors should be supported (not only the 3-4 colors that are explicitly linked to).
Solution:
Flash messages
Earlier, we saw how to programmatically redirect the user on form submission:
There's an important UX feature missing from this, however: there's no confirmation message! We aren't confirming for the user that their message was received.
A common pattern in full-stack applications is to use flash messages. A flash message is a notification that shows up on navigation, usually to provide additional context about the route change that just happened.
For example, we can use a flash message here to confirm that the message was sent:
In this exercise, you'll use the Toast
component we built in the second project. By strategically creating a new toast as the user is redirected, it effectively becomes a flash message!
The relevant pages are /exercises/02-flash-messages
and /exercises/02-flash-messages/contact
.
Acceptance Criteria:
- Submitting the contact form should redirect the user to the exercise homepage (
/exercises/02-flash-messages
). - Upon redirection, a confirmation message should be shown, using the
Toast
component. You should also make use of theToastShelf
andToastProvider
components from the previous project. - You don't have to use localStorage or cookies or anything like that. React context alone should be sufficient.
Solution: