generated from gabrielduete/frontend-template-nextjs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from gabrielduete/feat/create-navbar
feat: create navbar
- Loading branch information
Showing
18 changed files
with
316 additions
and
24 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
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
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
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,5 @@ | ||
describe('<MobileNavBar />', () => { | ||
it.todo('render texts correctly') | ||
|
||
it.todo('toggles the NavBar when BackIcon is clicked') | ||
}) |
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,39 @@ | ||
import { useState } from 'react' | ||
|
||
import { SoundClickButton } from '../../../utils/Sounds/index' | ||
import Equalizer from '../../Equalizer' | ||
import { navBarMock } from '../Navbar.mock' | ||
import * as S from './styles' | ||
|
||
const DesktopNavBar = () => { | ||
const [isOpen, setIsOpen] = useState(true) | ||
|
||
const closeNavBar = () => { | ||
SoundClickButton() | ||
setIsOpen(!isOpen) | ||
} | ||
|
||
return ( | ||
<> | ||
<S.Wrapper showNavBar={isOpen}> | ||
<S.NavBar> | ||
{navBarMock.map(({ name }, idx) => ( | ||
<S.Item key={idx}> | ||
<S.Link>{name}</S.Link> | ||
</S.Item> | ||
))} | ||
</S.NavBar> | ||
<S.RollbackContainer> | ||
<Equalizer /> | ||
<S.BackIcon onClick={closeNavBar} /> | ||
<div /> | ||
</S.RollbackContainer> | ||
</S.Wrapper> | ||
<S.WrapperColapsed showNavBar={!isOpen}> | ||
<S.GoIcon onClick={closeNavBar} /> | ||
</S.WrapperColapsed> | ||
</> | ||
) | ||
} | ||
|
||
export default DesktopNavBar |
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,113 @@ | ||
import ArrowBackIcon from '@mui/icons-material/ArrowBack' | ||
import ArrowForwardIcon from '@mui/icons-material/ArrowForward' | ||
import { SvgIconProps } from '@mui/material' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import medias from '~/src/enums/medias' | ||
|
||
const createIconStyles = (Icon: React.ComponentType<SvgIconProps>) => styled( | ||
Icon | ||
)` | ||
width: 35px; | ||
height: 35px; | ||
cursor: pointer; | ||
transition: 0.3s; | ||
color: var(--green-white); | ||
&:hover { | ||
color: var(--white); | ||
} | ||
` | ||
|
||
export const Wrapper = styled.nav<{ showNavBar: boolean }>` | ||
display: flex; | ||
flex-direction: column; | ||
height: calc(100vh - 120px); | ||
margin-top: 70px; | ||
overflow-y: auto; | ||
display: ${({ showNavBar }) => !showNavBar && 'none'}; | ||
@media (max-width: ${medias.maxTablet}) { | ||
display: none; | ||
} | ||
` | ||
|
||
export const WrapperColapsed = styled.nav<{ showNavBar: boolean }>` | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
height: 100vh; | ||
overflow-y: auto; | ||
padding: calc(var(--spacing-basic-small) - 2px); | ||
background-color: var(--green); | ||
border: 1px solid var(--green-white); | ||
display: ${({ showNavBar }) => !showNavBar && 'none'}; | ||
@media (max-width: ${medias.maxTablet}) { | ||
display: none; | ||
} | ||
` | ||
|
||
export const NavBar = styled.div` | ||
width: 280px; | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--spacing-basic-small); | ||
overflow-y: auto; | ||
::-webkit-scrollbar { | ||
width: 2px; | ||
} | ||
::-webkit-scrollbar-button { | ||
background-color: var(--black); | ||
} | ||
::-webkit-scrollbar-track-piece { | ||
background-color: var(--black); | ||
} | ||
::-webkit-scrollbar-thumb { | ||
background-color: var(--white); | ||
} | ||
` | ||
|
||
export const Item = styled.div` | ||
display: flex; | ||
align-items: center; | ||
width: 100%; | ||
transition: 0.3s; | ||
padding: var(--spacing-basic-small) 0; | ||
cursor: pointer; | ||
&:hover { | ||
background: var(--green); | ||
a { | ||
color: var(--white); | ||
} | ||
} | ||
` | ||
|
||
export const Link = styled.a` | ||
font-size: var(--font-small); | ||
padding-left: var(--spacing-basic); | ||
` | ||
|
||
export const RollbackContainer = styled.div` | ||
max-width: 280px; | ||
height: 60px; | ||
color: var(--green-white); | ||
background-color: var(--green); | ||
border: 1px solid var(--green-white); | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-around; | ||
padding: 0 10px; | ||
` | ||
|
||
export const BackIcon = createIconStyles(ArrowBackIcon) | ||
|
||
export const GoIcon = createIconStyles(ArrowForwardIcon) |
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,5 @@ | ||
describe('<MobileNavBar />', () => { | ||
it.todo('render texts correctly') | ||
|
||
it.todo('toggles the NavBar when BackIcon is clicked') | ||
}) |
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,24 @@ | ||
import React, { useState } from 'react' | ||
|
||
import { navBarMock } from '../Navbar.mock' | ||
import * as S from './styles' | ||
|
||
const MobileNavBar = () => { | ||
const [isOpen, setIsOpen] = useState(false) | ||
|
||
return ( | ||
<S.Container> | ||
<S.IconOpen onClick={() => setIsOpen(true)} /> | ||
<S.WrapperContent isOpen={isOpen}> | ||
<S.IconClose onClick={() => setIsOpen(false)} /> | ||
<S.WrapperLinks> | ||
{navBarMock.map(({ name }, idx) => { | ||
return <S.Link key={idx}>{name}</S.Link> | ||
})} | ||
</S.WrapperLinks> | ||
</S.WrapperContent> | ||
</S.Container> | ||
) | ||
} | ||
|
||
export default MobileNavBar |
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,57 @@ | ||
import CloseIcon from '@mui/icons-material/Close' | ||
import MenuIcon from '@mui/icons-material/Menu' | ||
import { SvgIconProps } from '@mui/material' | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import medias from '~/src/enums/medias' | ||
|
||
type addStyleIcon = { | ||
Icon: React.ComponentType<SvgIconProps> | ||
alignSelfEnd?: boolean | ||
} | ||
|
||
const addStyledIcon = ({ Icon, alignSelfEnd }: addStyleIcon) => styled(Icon)` | ||
align-self: ${alignSelfEnd && 'flex-end'}; | ||
color: var(--green-white); | ||
cursor: pointer; | ||
transition: 0.1s; | ||
&:active { | ||
color: var(--white); | ||
} | ||
` | ||
|
||
export const Container = styled.nav` | ||
@media (min-width: ${medias.maxTablet}) { | ||
display: none; | ||
} | ||
` | ||
|
||
export const IconOpen = addStyledIcon({ Icon: MenuIcon }) | ||
|
||
export const IconClose = addStyledIcon({ Icon: CloseIcon, alignSelfEnd: true }) | ||
|
||
export const WrapperContent = styled.div<{ isOpen: boolean }>` | ||
width: 100%; | ||
height: 90vh; | ||
background-color: var(--green-dark); | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
display: ${({ isOpen }) => (isOpen ? 'flex' : 'none')}; | ||
flex-direction: column; | ||
align-items: center; | ||
overflow-y: scroll; | ||
` | ||
|
||
export const WrapperLinks = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
gap: var(--spacing-basic); | ||
` | ||
|
||
export const Link = styled.a` | ||
font-size: var(--font-medium); | ||
padding-left: var(--spacing-basic); | ||
cursor: pointer; | ||
` |
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,17 @@ | ||
export const navBarMock = [ | ||
{ | ||
name: 'Go', | ||
}, | ||
{ | ||
name: 'React', | ||
}, | ||
{ | ||
name: 'Nextjs', | ||
}, | ||
{ | ||
name: 'Vue', | ||
}, | ||
{ | ||
name: 'React', | ||
}, | ||
] |
This file was deleted.
Oops, something went wrong.
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,5 @@ | ||
export default { | ||
minMobile: '360px', | ||
maxMobile: '768px', | ||
maxTablet: '992px', | ||
} as const |
Oops, something went wrong.