Full-Stack course / Tools and the web
Status badges with one shared token
How to fetch and submit this exercise
Once: install the tool and connect your account.
curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon loginEach exercise: download it, edit the file named in the instructions, then submit.
gonomicon fetch fs-week-1/05-04-badge-variant-tokens
cd 05-04-badge-variant-tokens
gonomicon submitStatus badges with one shared token
Build three status badges that share one style and display distinct background colors.
Worked example: The badge--ok, badge--warn, and badge--error badges each compute to a different RGB background color, and none matches the page’s default badge color.
Rules and constraints
- Link
styles.cssfromindex.html. - Put exactly three status
<span>elements inside<div id="badges">, using the required classes. - Define a default color and give each status a distinct color.
- Use the same custom property for the badge background and the status colors. Each modifier rule should declare only that custom property.
- Keep hex and hsl color values in the four custom-property declarations; do not add JavaScript.
What you'll practice
- Defining and using a CSS custom property.
- Overriding a shared value with modifier classes.
- Checking the DOM and computed colors.
Run it
gonomicon fetch fs-week-1/05-04-badge-variant-tokens
cd 05-04-badge-variant-tokens
gonomicon test
gonomicon submit
Hints
- Compare the computed background colors of all three badges with one another and with the page default.
- Check whether the base badge rule reads the same custom property that the status classes change.
- Keep the four color values in the root default and the three modifier declarations; use the shared token for the badge background.