This is a solution to the Results summary component challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- View the optimal layout for the interface depending on their device's screen size
- See hover and focus states for all interactive elements on the page
- Bonus: Use the local JSON data to dynamically populate the content... DONE!
- Solution URL: Github repository
- Live Site URL: Github pages
- HTML5 markup
- CSS custom properties
- Flexbox
- CSS Grid
- Vanilla Javascript
- Practiced the application of CSS pseudo-class :nth-child()
- Found out how to render list items dynamically, in vanilla Javascript
- Fetching data from a json file required an http local server, so instead of the json file, a data array was created and written at the beginning of the script.js, to be called directly.
Styling list items
li:nth-child(1) {
background: hsla(0, 100%, 67%, 0.1);
}
li:nth-child(1) .item-left p {
color: var(--light-red);
font-weight: 700;
}
Render list items dynamically, from a data file.
const listEl = document.querySelector("ul");
data.forEach((item) => {
listEl.insertAdjacentHTML(
"beforeend",
`
<li>
<div class="item-left">
<img src=${item.icon} alt=${item.category} />
<p class="category-red">${item.category}</p>
</div>
<div class="item-right">
<p><span class="score-span">${item.score} </span><span>/ 100</span></p>
</div>
</li>
`
);
});
Continue improving my coding skills by developing challenging applications, like this one.
- Read JSON File into HTML - Adapted the Javascript snippet into this application.
- Website - Guillermo Dominguez
- Frontend Mentor - @memominguez
Thanks to all those who share their knowledge, free of charge, through video tutorials in the youtube platform.