CodeBlanks Logo Icon CodeBlanks

Project: Micro frontend and design system

Review the goal and steps of the micro frontend and design system project.

Project: Micro frontend and design system

In this project you will build a micro frontend combining a design system core, a server component page and concurrent features.

In the first step you write the Button component, the building block of the design system. The variant prop changes the appearance. In later lessons this button will be combined with a theme provider and a server page.

Each lesson's starting code includes the previous solution; the project grows step by step.

The variant prop

The Button component takes a variant prop. If variant === 'primary' the btn-primary class is applied; otherwise btn-secondary.

This pattern ensures consistent appearance in the design system. To add new variants you only extend the condition.

The button content is carried by children; this allows flexible usage.

Practice Write the Button component

Write Button. Take variant and children props. Compute className with variant === 'primary' ? 'btn-primary' : 'btn-secondary'. Return <button className={className}>{children}</button>. Export it.

Starter code

App.jsx
// Button.jsx

// Write the Button component here

Sample solution

App.jsx
function Button({ variant, children }) {
  const className = variant === 'primary' ? 'btn-primary' : 'btn-secondary';
  return <button className={className}>{children}</button>;
}
export default Button;

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 What is the first step of this project?

  • Writing a server page
  • Writing the Button component Correct answer
  • Adding concurrent search
  • Setting up a custom renderer

Explanation: First you write Button, the building block.

2 Fill in the blank: select the class with variant

Question
function Button({ variant, children }) {
  const className = variant === 'primary' ? 'btn-primary' : '____';
  return <button className={className}>{children}</button>;
}
Answer
function Button({ variant, children }) {
  const className = variant === 'primary' ? 'btn-primary' : 'btn-secondary';
  return <button className={className}>{children}</button>;
}

Explanation: If not primary, the btn-secondary class is applied.

3 Match project steps

Term Meaning
Button Design system core
ThemeProvider Provides theme
ProductPage Server component page
SearchPanel Concurrent search

All lessons in Expert