This is a solution to the Advice generator app challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
- Click the button and receive a random piece of advice from a public API.
- Desktop view:
- Mobile view:
- Live Site URL: https://loganwoolf.github.io/fm-advice/
- Frontend Mentor Solution URL: https://www.frontendmentor.io/solutions/advice-generator-in-react-S1ZKd7bHq
- Semantic HTML5 markup
- CSS custom properties
- Flexbox
- Mobile-first workflow
- React - JS library
create-react-app
- Use JS to target effects to input type. CSS
:hover
pseudo-selector triggers on touch, and never releases and we don't want that!
const addHoverEffect = (e) => {
e.target.classList.add("button-hover");
};
const removeHoverEffect = (e) => {
e.target.classList.remove("button-hover");
};
return (
<button
onMouseEnter={addHoverEffect}
onMouseLeave={removeHoverEffect}
>
)
- Load an SVG as a React component
import { ReactComponent as Icon } from "../images/icon-dice.svg";
return (
<button>
<Icon>
</button>
)
- Need to find a way to make the App resize smoothly when loading new advice text.
- Website - Logan Woolf
- Frontend Mentor - @loganwoolf
- Twitter - @logan__woolf