-
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.
Add language switch menu + restyle top bar + breakpoint pagination (#33)
* Add language switch menu + restyle top bar * Limit pagination buttons to 6 for mobile devices * Create custom RoutedPagination with maxButtons breakpoint definition
- Loading branch information
1 parent
519e274
commit f894758
Showing
20 changed files
with
166 additions
and
87 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
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 { Button, Menu, MenuButton, MenuItem, MenuList, MenuProps } from '@chakra-ui/react' | ||
import { useTranslation } from 'react-i18next' | ||
import { FaChevronDown, FaChevronUp, FaGlobeAmericas } from 'react-icons/fa' | ||
import languages from '~i18n/languages.mjs' | ||
|
||
export const LanguagesList = () => { | ||
const { i18n } = useTranslation() | ||
|
||
const isAnyLanguageSelected = | ||
Object.keys(languages).some((l) => l === i18n.language) && languages.includes(i18n.language) | ||
|
||
return ( | ||
<> | ||
{languages.map((k: string) => ( | ||
<MenuItem | ||
key={k} | ||
onClick={() => { | ||
i18n.changeLanguage(k) | ||
}} | ||
display='flex' | ||
justifyContent='center' | ||
fontWeight={k === i18n.language ? 'bold' : ''} | ||
borderRadius='none' | ||
> | ||
{k.toUpperCase()} | ||
</MenuItem> | ||
))} | ||
</> | ||
) | ||
} | ||
|
||
export const LanguagesMenu = (props: Omit<MenuProps, 'children'>) => { | ||
const { t } = useTranslation() | ||
|
||
return ( | ||
<Menu> | ||
{({ isOpen }) => ( | ||
<> | ||
<MenuButton | ||
as={Button} | ||
aria-label={t('menu.burger_aria_label')} | ||
variant='rounded-ghost' | ||
sx={{ span: { margin: 'px' } }} | ||
rightIcon={isOpen ? <FaChevronUp /> : <FaChevronDown />} | ||
minW='none' | ||
size='sm' | ||
> | ||
<FaGlobeAmericas /> | ||
</MenuButton> | ||
<MenuList minW={16} mt={2}> | ||
<LanguagesList /> | ||
</MenuList> | ||
</> | ||
)} | ||
</Menu> | ||
) | ||
} |
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,9 @@ | ||
import { useBreakpointValue } from '@chakra-ui/react' | ||
import { RoutedPagination as Pagination, PaginationProps } from './Pagination' | ||
|
||
// Note this component is a custom definition of the pagination component that will end in chakra-components | ||
export const RoutedPagination = (props: PaginationProps) => { | ||
const maxButtons = useBreakpointValue({ base: 6, lg: 10 }) | ||
|
||
return <Pagination {...props} maxButtons={maxButtons} /> | ||
} |
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
Oops, something went wrong.
f894758
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.
π Published on https://vocdoni-explorer-dev.netlify.app as production
π Deployed on https://6683fa652abdb2615e0b67cc--vocdoni-explorer-dev.netlify.app
f894758
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.
π Published on https://vocdoni-explorer-stg.netlify.app as production
π Deployed on https://6683fa66b62bfa5fe73e89a0--vocdoni-explorer-stg.netlify.app