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

Advice Generator App using typescript

nikoProg 120

@nikoProg

Desktop design screenshot for the Advice generator app coding challenge

This is a solution for...

  • HTML
  • CSS
  • JS
  • API
2junior
View challenge

Design comparison


SolutionDesign

Solution retrospective


Any advice about the layout in general?

The button starts glowing upon hovering, but if you click it, the glow gets stuck, no matter where you move the mouse, until you click on something else. How can I make the button glow and stop glowing when I stop hovering? My solution is a bit of a hack, using ::after pseudoelement, so I am not sure how to fix it.

This was also my intro to typescript. I installed it, because I like that strongly-typed languages make it easier to fix some mistakes, so I hoped this could help. I didn't have much use of it yet, since the only script needed here is to fetch advice from the API.

Community feedback

David 8,000

@DavidMorgade

Posted

Hello man, congrats on finishing the challenge, I think I know why your button is getting the box-shadow effect when clicked.

You are using the :focus pseudoelement, this mean that your button will get the opacity prop every time is focused (when is clicked and you dont click in other elements), you dont need to set a focus or after to get the desired effect, you can remove both pseudoclasses and just keep :hover with these styles:

#btn:hover {
  box-shadow: 0 0 2em 0.5em hsl(150, 100%, 66%);
  transition: box-shadow 500ms linear;
}

Hope this helps, just with the :hover pseudoelement you will get the desired result.

1
Tim 100

@tlauffs

Posted

Try using the :hover Selector instead of an ::after pseudoelement to create the glow effect. It will only trigger on hover and you should only need a box-shadow to create the effect. You should also consider adding a :focus state for keyboard navigation as :hover states aren't shown.

1

@ArturHarutyunyan1

Posted

Make your .advice-container centered. *{margin: 0; padding: 0; box-sizing: border-box}. Remove body{padding: 10%;} and set body height to body{height: 100vh}

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