-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: example of a button on the cubesats page + fixes
- Loading branch information
1 parent
30e9d3a
commit d592dec
Showing
6 changed files
with
2,438 additions
and
912 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import NavHeader from './NavHeader'; | ||
import NavMenu from './NavMenu'; | ||
import style from 'styles/NavBarProjects.module.css'; | ||
import { Button } from '@mui/material'; | ||
|
||
function NavBarProjects(props) { | ||
const [menu, setMenuState] = useState(false); | ||
const [scrollDir, setScrollDir] = useState('top'); | ||
|
||
const toggleMenu = (open) => { | ||
setMenuState(open); | ||
}; | ||
|
||
useEffect(() => { | ||
const closeMenu = () => { | ||
toggleMenu(false); | ||
}; | ||
|
||
window.addEventListener('resize', closeMenu); | ||
|
||
return () => window.removeEventListener('resize', closeMenu); | ||
}, []); | ||
|
||
useEffect(() => { | ||
toggleMenu(false); | ||
const threshold = 5; | ||
const topThreshHold = 90; | ||
|
||
let lastYPos = window.pageYOffset; | ||
let ticking = false; | ||
|
||
const updateScrollDir = () => { | ||
const currYPos = window.pageYOffset; | ||
|
||
if (currYPos > topThreshHold) { | ||
if (Math.abs(currYPos - lastYPos) < threshold) { | ||
ticking = false; | ||
return; | ||
} | ||
setScrollDir(currYPos > lastYPos ? 'down' : 'up'); | ||
lastYPos = currYPos > 0 ? currYPos : 0; | ||
} else { | ||
setScrollDir('top'); | ||
} | ||
ticking = false; | ||
}; | ||
|
||
const onScroll = () => { | ||
if (!ticking) { | ||
window.requestAnimationFrame(updateScrollDir); | ||
ticking = true; | ||
} | ||
}; | ||
|
||
window.addEventListener('scroll', onScroll); | ||
|
||
return () => window.removeEventListener('scroll', onScroll); | ||
}, [scrollDir]); | ||
|
||
return ( | ||
|
||
<div | ||
className={ | ||
scrollDir === 'down' | ||
? style.navBarContainerDeactive | ||
: style.navBarContainerActive | ||
}> | ||
<div | ||
className={style.navBarContainerBackground} | ||
style={{ | ||
backgroundColor: scrollDir === 'top' ? 'transparent' : 'black', | ||
}} | ||
/> | ||
<NavHeader | ||
toggleMenu={toggleMenu} | ||
isMenuOpen={menu} | ||
/> | ||
<NavMenu isMenuOpen={menu} /> | ||
|
||
<Button | ||
variant="contained" | ||
color="primary" | ||
className={style.fixedButton} | ||
href='/projetos' | ||
> | ||
Voltar para página de projetos | ||
</Button> | ||
</div> | ||
); | ||
} | ||
|
||
export default NavBarProjects; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,24 @@ | ||
import { Button, Typography } from '@mui/material'; | ||
import Grid from '@mui/material/Unstable_Grid2'; | ||
import React, { useState } from 'react'; | ||
|
||
export default function CubeSats() { | ||
// precisa colocar a navbar aqui | ||
return ( | ||
<Grid container sx={{border: 1, borderColor: 'red'}}> | ||
<Grid sm={12} md={12} p={2}> | ||
<Button size="small" color="primary" href='/projetos'> | ||
Voltar para página de projetos | ||
</Button> | ||
<> | ||
{/* Espaços vazios so pra testar mesmo*/} | ||
<Grid container sx={{ minHeight: '100vh', padding: 2 }}> | ||
<Grid item xs={12} md={6} sx={{ border: 1, borderColor: 'red', padding: 2 }}> | ||
</Grid> | ||
</Grid> | ||
|
||
<Grid sm={12} md={6} p={2} sx={{border:1}}> | ||
<Typography gutterBottom variant="h2" component="div" > | ||
Cubesats | ||
</Typography> | ||
<Grid container sx={{ minHeight: '100vh', padding: 2 }}> | ||
<Grid item xs={12} md={6} sx={{ border: 1, borderColor: 'blue', padding: 2 }}> | ||
</Grid> | ||
</Grid> | ||
</Grid> | ||
) | ||
|
||
<Grid container sx={{ minHeight: '100vh', padding: 2 }}> | ||
<Grid item xs={12} md={6} sx={{ border: 1, borderColor: 'green', padding: 2 }}> | ||
</Grid> | ||
</Grid> | ||
</> | ||
); | ||
} |
Oops, something went wrong.