Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted over 3 years ago

NFT Card using Reactjs and Styled Components

react, styled-components
rebecca•60
@rebeccaaaaaaaaaaa
A solution to the NFT preview card component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


How are you guys? Here's my solution to the challenge, I'm a beginner but I'm always looking to improve and study. I've been using this type of challenge to apply what I've been learning, any improvement opinion is welcome!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Raymart Pamplona•16,040
    @pikapikamart
    Posted over 3 years ago

    Hey, great work on this one. Right now, the overall layout looks huge both desktop and mobile state.

    Krisztina Kovari already gave really great feedback on this and I second to all her feedback. Here are some suggestions for the site as well:

    • Don't use width: 100vw since this will only add a horizontal scrollbar at the bottom, since this value does not account the vertical scrollbar's width.
    • Avoid using height: 100vh on a large container like the div that holds the nft-card as this makes the element's height capped based on the viewport/screen's height. Instead use min-height: 100vh so that the element will expand if it needs to.
    • Always have a main element to wrap the main content of the site. For this use main tag on the div after the #root selector. This way, your content will be inside a main landmark.
    • Like what Krisztina had said, the :hover state for the preview image is not created. Just a quick suggestion, if you are going to implement the :hover state make sure that you are going to use an interactive element that could be nesting the img. Because as you may remember, an img tag is not an interactive element. You could use either a tag or button, depending on whatever you think clicking the image would do.
    • For the nft image, you could use the nft name as the alt value since it is already present. You could use something like alt="nft Equilibrium #3429".
    • For the nft name, since it is an interactive component, use an a tag inside the h1 so that it will be interacted with.
    • For the eth-icon and the clock-icon, you could use alt="" and aria-hidden="true" on both of it since on this one, it is acting as decorative images. Decorative images are just images that doesn't contribute to the overall content of the site.
    • Also, when using img tag, you don't need to add words that relates to "graphic" such as "icon" and others, since img is already an image so no need to describe it as one.
    • For the person's img, you could use the person's name as well since it makes sense to do so since on this layout, it is showing the creator of the nft.
    • Change the span inside the person's name to use a tag so that it will be interactive.
    • Lastly, just re-styling the whole card or the size of it so that it will closely match the design's dimension.

    Aside from those, great job again on this one.

    Marked as helpful
  • Krisztina Kovari•60
    @krystonen
    Posted over 3 years ago

    Hi Rebecca,

    Nice work! I like that you used React and styled components. I have a few comments on your solution (I worked on it myself recently).

    • Check design for the hover state, I found it an interesting challenge in itself (tip: use pseudo elements.)
    • Try to resolve accessibility issues flagged by the report
    • Can you use more meaningful semantic HTML for your markup?
    • Would you consider using css variables styled components ( I actually looked this up for myself as well: https://www.joshwcomeau.com/css/css-variables-for-react-devs/ )
    • Responsiveness: On mobile the card doesn't appear fully. On desktop the card seems larger than on the design. My tips: try using relative units instead of fixed pixels where it makes sense. add media query if relative units don't do the job.
    Marked as helpful

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
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit 1st-party linked stylesheets, and styles within <style> tags.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub