Loading repository data…
Loading repository data…
avalonxii / repository
Practicando maquetación con un ejercicio de frontend Mentor, con React.js, SCSS y Framer Motion, desplegado en firebase
This is a solution to the News homepage challenge on Frontend Mentor. Frontend Mentor challenges help you improve your coding skills by building realistic projects.
Users should be able to:
I've started seeing what would be the better html schema and layouts (flexbox and grid), then continue with coding the menu and finishing with the news, everything was great but then I had some problems with fonts and finally I made the animations nad re-organize the code to make it easier to read.
// AnimationsContext.jsx
export default function AnimationsContextProvider(props) {
const [IsMobile, setIsMobile] = useState(false)
const [windowWidth, setWindowWidth] = useState(window.innerWidth)
useEffect(() => {
const handleWindowResize = () => {
setWindowWidth(window.innerWidth)
}
window.addEventListener('resize', handleWindowResize)
setIsMobile(windowWidth <= 900)
return () => {
window.removeEventListener('resize', handleWindowResize)
}
})
const enlacesMenuVariant = IsMobile
? {
// initial
closed: {
opacity: 0,
x: '100vw'
},
// animate
open: {
opacity: 1,
x: 0,
transition: {
duration: 0.4
}
}
}
: {
closed: { opacity: 1 },
open: { opacity: 1 }
}
return (
<AnimationContext.Providervalue={{enlacesMenuVariant}}>
{props.children}
</AnimationContext.Providervalue>
)
}
// Menu.jsx - go to this file to see al the code, this just and "how I use this" example :)
import { motion } from 'framer-motion'
import { AnimationContext } from '../../context/AnimationsContext'
const {enlacesMenuVariant} = useContext(AnimationContext)
<motion.li
key={link}
variants={enlacesMenuVariant}
whileTap={whileTapLinkVariant}
whileHover={whileHoverLinkMenuVariant}
>
{link}
</motion.li>