-
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 #49 from angelod1as/i18n
Add i18n functionalities, a major data overhaul
- Loading branch information
Showing
42 changed files
with
588 additions
and
150 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 @@ | ||
TODO: Current projects |
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 |
---|---|---|
|
@@ -8,4 +8,8 @@ module.exports = { | |
}, | ||
] | ||
}, | ||
i18n: { | ||
locales: ['en', 'pt'], | ||
defaultLocale: 'en', | ||
}, | ||
} |
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,15 @@ | ||
import { useRouter } from 'next/router' | ||
import { StyledHome, Wrapper } from './styles' | ||
|
||
export default function HomeButton() { | ||
const { push, asPath } = useRouter() | ||
|
||
if (asPath !== '/') { | ||
return ( | ||
<Wrapper> | ||
<StyledHome onClick={() => push('/')}>Home</StyledHome> | ||
</Wrapper> | ||
) | ||
} | ||
return <div /> | ||
} |
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,33 @@ | ||
import styled from 'styled-components' | ||
|
||
export const Wrapper = styled.div` | ||
display: flex; | ||
justify-content: flex-start; | ||
` | ||
|
||
export const StyledHome = styled.button` | ||
position: relative; | ||
background-color: transparent; | ||
border: none; | ||
font-family: 'Montserrat', sans-serif; | ||
font-weight: 700; | ||
font-size: 16px; | ||
line-height: 25px; | ||
cursor: pointer; | ||
text-transform: lowercase; | ||
color: ${p => p.theme.color.black}; | ||
&:before { | ||
transition: left 0.3s ease; | ||
content: '‹'; | ||
position: absolute; | ||
left: -8px; | ||
} | ||
&:hover { | ||
&:before { | ||
left: -4px; | ||
content: '«'; | ||
} | ||
} | ||
` |
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,44 @@ | ||
import { useRouter } from 'next/router' | ||
import { Dispatch, SetStateAction } from 'react' | ||
import { BG, Flag, Switch, Slider } from './styles' | ||
|
||
interface LocaleSwitcherProps { | ||
setLoading: Dispatch<SetStateAction<boolean>> | ||
} | ||
|
||
export default function LocaleSwitcher({ setLoading }: LocaleSwitcherProps) { | ||
const router = useRouter() | ||
|
||
const { locales, locale, asPath } = router | ||
|
||
const changeLanguage = () => { | ||
setLoading(true) | ||
const newLocale = locales.filter(each => each !== locale)[0] | ||
router | ||
.push(asPath, asPath, { locale: newLocale }) | ||
.then(() => setLoading(false)) | ||
} | ||
|
||
return ( | ||
<BG> | ||
<Flag> | ||
<span role="img" aria-label="Portuguese"> | ||
🇧🇷 | ||
</span> | ||
</Flag> | ||
<Switch> | ||
<input | ||
type="checkbox" | ||
onChange={changeLanguage} | ||
checked={locale !== 'pt'} | ||
/> | ||
<Slider /> | ||
</Switch> | ||
<Flag> | ||
<span role="img" aria-label="English"> | ||
🇬🇧 | ||
</span> | ||
</Flag> | ||
</BG> | ||
) | ||
} |
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,52 @@ | ||
import styled from 'styled-components' | ||
|
||
export const BG = styled.div` | ||
display: flex; | ||
padding: 15px 0; | ||
justify-content: center; | ||
` | ||
|
||
export const Flag = styled.div` | ||
cursor: pointer; | ||
margin: 0 10px; | ||
font-size: 20px; | ||
transition: transform 0.2s ease; | ||
` | ||
|
||
export const Slider = styled.span` | ||
position: absolute; | ||
cursor: pointer; | ||
top: 0; | ||
left: 0; | ||
right: 0; | ||
bottom: 0; | ||
background-color: #ccc; | ||
transition: 0.2s; | ||
border-radius: 34px; | ||
&:before { | ||
position: absolute; | ||
content: ''; | ||
height: 16px; | ||
width: 16px; | ||
left: 3px; | ||
bottom: 2px; | ||
background-color: white; | ||
transition: 0.2s; | ||
border-radius: 50%; | ||
} | ||
` | ||
|
||
export const Switch = styled.label` | ||
position: relative; | ||
width: 40px; | ||
input { | ||
opacity: 0; | ||
width: 0; | ||
height: 0; | ||
} | ||
input:checked + ${Slider}:before { | ||
transform: translateX(18px); | ||
} | ||
` |
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 @@ | ||
import { Dispatch, SetStateAction } from 'react' | ||
import LocaleSwitcher from './LocaleSwitcher' | ||
import HomeButton from './HomeButton' | ||
import { Wrapper } from './styles' | ||
|
||
interface BottomBarProps { | ||
setLoading: Dispatch<SetStateAction<boolean>> | ||
} | ||
|
||
export default function BottomBar({ setLoading }: BottomBarProps) { | ||
return ( | ||
<Wrapper> | ||
<HomeButton /> | ||
<LocaleSwitcher {...{ setLoading }} /> | ||
</Wrapper> | ||
) | ||
} |
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,16 @@ | ||
import styled from 'styled-components' | ||
|
||
export const Wrapper = styled.div` | ||
position: fixed; | ||
bottom: 0; | ||
left: 0; | ||
z-index: 10; | ||
width: 100%; | ||
/* display: flex; | ||
justify-content: space-between; | ||
align-items: center; */ | ||
display: grid; | ||
grid-template-columns: repeat(3, 1fr); | ||
background-color: ${p => p.theme.color.white}; | ||
padding: 0 20px; | ||
` |
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,17 @@ | ||
import { useTranslation } from '@i18n/i18n' | ||
import { useRouter } from 'next/router' | ||
import { Wrapper, Square, Word, BG } from './styles' | ||
|
||
export default function Loading() { | ||
const { locale } = useRouter() | ||
const t = useTranslation(locale) | ||
|
||
return ( | ||
<Wrapper> | ||
<Word>{t('loading')}</Word> | ||
<Square> | ||
<BG /> | ||
</Square> | ||
</Wrapper> | ||
) | ||
} |
Oops, something went wrong.
fe31a57
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: