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

👨‍💻 QR Code Component (HTML + CSS + JS + Dark-Light Theme)

accessibility
Adriano•42,870
@AdrianoEscarabote
A solution to the QR code component challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


👨‍💻 Hello guys. This is my resolution for the QR Code Component challenge. I was challenged by my friend @correlucas to redo this challenge and improve it.

I added some details:

  • 🎨 Dark and Light Theme button
  • 👨‍🎨 Custom QR Code image
  • 🧚‍♂️ Custom colors
  • 👨‍💻 Image hover effect

Feel free to leave feedback on how I can improve my code. 😊 Thanks!

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Rynex Akil•100
    @rynex-zv
    Posted over 2 years ago

    The only thing that is missing in dark theme is:

    .attribution{
    color: white;
    }
    

    Will done!

    Marked as helpful
  • Julio Cinquina•270
    @JulioCinquina
    Posted almost 3 years ago

    Parabéns pela solução, Adriano! Sua versão personalizada ficou incrível!

    Achei bem legal, fiquei com vontade de fazer um modo escuro para algum desafio daqui do site.

    Vou deixar duas sugestões para melhorar a acessibilidade da página:

    • Dar um outline para o botão na pseudoclasse :focus-visible. Assim, ao navegar com a tecla Tab, vai aparecer um contorno em volta do botão quando o foco estiver sobre ele.
    • Vi que você colocou um aria-label descritivo no botão, o que é ótimo, agora só precisa atualizá-lo ao alternar entre os modos. Você pode fazer isso com o método setAttribute() do elemento:
    const button = document.getElementById('iconTheme');
    button.setAttribute('aria-label', 'activate light mode');
    // ou...
    button.setAttribute('aria-label', 'activate dark mode');
    

    Se quiser ir ainda mais além, você pode colocar uma transição entre os modos para a mudança entre claro e escuro não ser tão brusca.

    Dei uma pesquisada e parece que os degradês não são "transicionáveis" pela propriedade transition, então você teria que fazer uma pequena gambiarra com um pseudoelemento e a opacidade. Dá uma olhada neste CodePen do Chris Coyier: Transitioning Gradients (fonte: artigo Transitioning Gradients, Chris Coyier [CSS-Tricks]).

    Espero que as sugestões sejam úteis. Parabéns mais uma vez e keep coding! 💻

    Marked as helpful
  • Lucas 👾•104,160
    @correlucas
    Posted almost 3 years ago

    ⭐Fala Adriano! Parabéns por essa belissima solução.⭐

    Até quem enfim alguém que fez algo diferente aqui, mandou mto!

    Gostei muito da versão BLACK, na versão light eu só mudaria o gradiente do fundo pra dar um pouco mais de contraste, as cores que eu usaria seriam.

    .light-theme {    --bg-color1: #0b0b0b;
        --bg-color2: #0d5ef5;
    }
    

    Dois sites que vão te ajudar muito a trabalhar com gradientes são:

    https://gradienthunt.com/ -- > pra referencia de cores e gradientes ja prontos https://cssgradient.io/ ---> pra voce criar seus gradientes e depois so copiar e colar no CSS.

    👾Minha avaliação para sua solução: ⭐⭐⭐⭐⭐

    Parabéns lek.

    Marked as helpful
  • David•7,960
    @DavidMorgade
    Posted almost 3 years ago

    Hello Adriano, your solution looks awesome, I love the background gradients, I think you really nailed it, congratulations!

    The only little thing that I would change from the styles is the 'coded by' in your attribution when is at dark mode, maybe swapping the color to white, cause in dark mode is hard to appreciate what it says!.

    Also would like to challenge you even further! (if you want and if you have the time to try it), try getting the prefers-color-scheme from the user, would also be cool to have your App save the state of the theme mode in localStorage!

    Really awesome job, keep it going, this type of personal hand challenges are the one I most like.

    Marked as helpful
  • OLUMIDE MICHEAL•270
    @codewithmide
    Posted almost 3 years ago

    I love the dark theme you added. You're a real programmer😂

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 all CSS, SCSS and Less files in your repository.

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.

How does the JavaScript validation report work?

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

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

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

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

Oops! 😬

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

Log in with GitHub