Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found
Not Found

Submitted

Results Summary Component using React and Tailwind

@kevatoloco

Desktop design screenshot for the Results summary component coding challenge

This is a solution for...

  • HTML
  • CSS
1newbie
View challenge

Design comparison


SolutionDesign

Solution retrospective


This is my first time using tailwind. I was wondering if there could be more efficient ways to structure or write my code. What are some good practices that I am missing? Thank you!

Community feedback

@gracebir

Posted

Hey Kevin, you did a great job. I would like to leave some feedbacks:

  • About the Jsx structure in your App.js file, avoid putting a meta tag inside react component, what you can do instead is to put all links in the public/inde.html file. Means you need to remove the head here:
import logo from './logo.svg';
import './App.css';

function App() {
return (
    <>
<head>
<link rel="preconnect" href="https://fonts.googleapis.com"/>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
<link href="https://fonts.googleapis.com/css2?family=Hanken+Grotesk:wght@500;700;800&display=swap" rel="stylesheet"/>
</head>
    
<div className='h-screen flex items-center justify-center'>
<div className='flex mobile:flex-col w-max font-hanken rounded-lg bg-white box-content drop-shadow-2xl'>

<div className='bg-gradient-to-b from-primary-100 to-primary-200 flex-1 text-center rounded-lg box-content p-6 w-max' >
<h1 className='pb-6 text-gray-300 font-bold'>
Your Result
</h1>
  • for tailwindcss, the only one thing that you just have to understand that it is mobile-first based, which means you don't really need to override the screen size, for this tag, <div className='flex mobile:flex-col w-max font-hanken rounded-lg bg-white box-content drop-shadow-2xl'> you could have <div className='flex flex-col lg:flex-row w-full font-hanken rounded-lg bg-white box-content drop-shadow-2xl'>, means flex-direction will be a column on mobile and row on desktop.
theme: {

screens: {
'lg': {'max': '1440px'},
// => @media (min-width: 375px) { ... }

'mobile': {'max':'375px'},
// => @media (min-width: 1440px) { ... }
},
extend: {
colors: {
'primary': {
100: 'hsl(252, 100%, 67%)',
200: 'hsl(241, 81%, 54%)',
},

Also by putting the screen property directly in the theme property, means you are overriding the existing tailwind class properties, if you want to create custom properties, put them in the extend property and create different names from existing class properties.

Marked as helpful

1

@kevatoloco

Posted

Hello @gracebir! This is really helpful and I will definitely keep this in mind for my next challenge. Thank you so much. I really appreciate you for taking the time to give me feedback!

0

@gracebir

Posted

you're welcome @kevin

0

Please log in to post a comment

Log in with GitHub
Discord logo

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord