Skip to content

Commit

Permalink
Merge pull request #1003 from basedosdados/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
AldemirLucas authored Oct 30, 2024
2 parents 056f67f + bc17764 commit ccb3f47
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 27 deletions.
123 changes: 113 additions & 10 deletions next/components/atoms/LanguageSelector.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,129 @@
import { Menu, MenuButton, MenuList, MenuItem, Button } from "@chakra-ui/react";
import { Menu, MenuButton, MenuList, MenuItem, Tooltip } from "@chakra-ui/react";
import { useRouter } from "next/router";
import { useTranslation } from "next-i18next";
import { useState } from "react";
import LanguageIcon from "../../public/img/icons/languageIcon";

export default function LanguageSelector() {
const { locale } = useRouter();
const router = useRouter();
const [showTooltip, setShowTooltip] = useState(false);

const changeLanguage = (locale) => {
router.push(router.pathname, router.asPath, { locale });
};

const getTooltipText = () => {
switch(locale) {
case 'pt':
return 'Língua';
case 'en':
return 'Language';
case 'es':
return 'Idioma';
default:
return 'Language';
}
};

return (
<Menu>
<MenuButton as={Button} rightIcon={<LanguageIcon />} variant="ghost">
{locale === 'pt' ? 'PT' : locale === 'en' ? 'EN' : 'ES'}
</MenuButton>
<MenuList>
<MenuItem onClick={() => changeLanguage('pt')}>Português</MenuItem>
<MenuItem onClick={() => changeLanguage('en')}>English</MenuItem>
<MenuItem onClick={() => changeLanguage('es')}>Español</MenuItem>
</MenuList>
<Menu
onOpen={() => setShowTooltip(false)}
>
{({ isOpen }) => (
<>
<Tooltip
backgroundColor="#FFF"
borderRadius="8px"
letterSpacing="0.1px"
lineHeight="18px"
fontWeight="400"
fontSize="12px"
fontFamily="Roboto"
marginTop="-4px"
color="#252A32"
padding="8px 12px"
boxShadow="0 2px 16px rgba(0, 0, 0, 0.16)"
placement="top-start"
label={getTooltipText()}
isOpen={showTooltip && !isOpen}
onClose={() => setShowTooltip(false)}
>
<MenuButton
aria-label="Language selector"
width="36px"
height="36px"
borderRadius="50%"
zIndex="11"
onMouseEnter={() => setShowTooltip(true)}
onMouseLeave={() => setShowTooltip(false)}
>
<LanguageIcon
alt="language selector"
justifyContent="center"
width="36px"
height="36px"
fill="#878A8E"
/>
</MenuButton>
</Tooltip>
<MenuList
boxShadow="0px 1.5px 16px rgba(0, 0, 0, 0.16)"
_focus={{boxShadow: "0px 1.5px 16px rgba(0, 0, 0, 0.16) !important"}}
padding="16px 0 6px"
borderRadius="8px"
zIndex="11"
color="#252A32"
minW="100px"
>
<MenuItem
onClick={() => changeLanguage('pt')}
letterSpacing="0.1px"
lineHeight="18px"
fontWeight="400"
fontSize="12px"
fontFamily="Roboto"
color="#252A32"
backgroundColor="#FFF"
padding="0 16px 10px"
_focus={{backgroundColor: "transparent"}}
_hover={{backgroundColor: "transparent", opacity: "0.7"}}
>
Português
</MenuItem>
<MenuItem
onClick={() => changeLanguage('en')}
letterSpacing="0.1px"
lineHeight="18px"
fontWeight="400"
fontSize="12px"
fontFamily="Roboto"
color="#252A32"
backgroundColor="#FFF"
padding="0 16px 10px"
_focus={{backgroundColor: "transparent"}}
_hover={{backgroundColor: "transparent", opacity: "0.7"}}
>
English
</MenuItem>
<MenuItem
onClick={() => changeLanguage('es')}
letterSpacing="0.1px"
lineHeight="18px"
fontWeight="400"
fontSize="12px"
fontFamily="Roboto"
color="#252A32"
backgroundColor="#FFF"
padding="0 16px 10px"
_focus={{backgroundColor: "transparent"}}
_hover={{backgroundColor: "transparent", opacity: "0.7"}}
>
Español
</MenuItem>
</MenuList>
</>
)}
</Menu>
);
}
3 changes: 2 additions & 1 deletion next/components/organisms/DatasetCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ export default function DatasetCard({
<HStack
spacing={0}
justifyContent="space-between"
width="220px"
width="100%"
gap="20px"
>
<Link
target="_blank"
Expand Down
12 changes: 8 additions & 4 deletions next/pages/_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ function MyApp({ Component, pageProps }) {
<meta name="robots" content="noindex" />
)}
{/* <meta/> para não noindex ambientes de development e staging */}
<link rel="icon" type="image/ico" href="/favicon.ico" />
{locale === 'en' ?
<link rel="icon" type="image/ico" href="/favicon_en.ico"/>
:
<link rel="icon" type="image/ico" href="/favicon_default.ico"/>
}
<link
rel="image_src"
href="https://storage.googleapis.com/basedosdados-website/thumbnails/2022/thumbnail_padrao.png"
href={`https://storage.googleapis.com/basedosdados-website/thumbnails/${locale}/general.png`}
/>

<title>{locale === 'en' ? 'Data Basis' : locale === 'es' ? 'Base de los Datos' : 'Base dos Dados'}</title>
Expand All @@ -52,14 +56,14 @@ function MyApp({ Component, pageProps }) {
<meta name="twitter:creator" content="@basedosdados" />
<meta
name="twitter:image"
content="https://storage.googleapis.com/basedosdados-website/thumbnails/2022/thumbnail_padrao.png"
content={`https://storage.googleapis.com/basedosdados-website/thumbnails/${locale}/general.png`}
key="twimage"
/>

{/* Open Graph */}
<meta
property="og:image"
content="https://storage.googleapis.com/basedosdados-website/thumbnails/2022/thumbnail_padrao.png"
content={`https://storage.googleapis.com/basedosdados-website/thumbnails/${locale}/general.png`}
key="ogimage"
/>
<meta
Expand Down
6 changes: 3 additions & 3 deletions next/pages/dataset/[dataset].js
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,16 @@ export default function DatasetPage ({ dataset }) {

<link
rel="image_src"
href="https://storage.googleapis.com/basedosdados-website/thumbnails/2022/thumbnail_conjunto.png"
href={`https://storage.googleapis.com/basedosdados-website/thumbnails/${locale}/dataset.png`}
/>
<meta
property="og:image"
content="https://storage.googleapis.com/basedosdados-website/thumbnails/2022/thumbnail_conjunto.png"
content={`https://storage.googleapis.com/basedosdados-website/thumbnails/${locale}/dataset.png`}
key="ogimage"
/>
<meta
name="twitter:image"
content="https://storage.googleapis.com/basedosdados-website/thumbnails/2022/thumbnail_conjunto.png"
content={`https://storage.googleapis.com/basedosdados-website/thumbnails/${locale}/dataset.png`}
key="twimage"
/>
<meta
Expand Down
Binary file added next/public/favicon_default.ico
Binary file not shown.
Binary file not shown.
10 changes: 5 additions & 5 deletions next/public/img/logos/bd_logo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions next/public/img/logos/db_logo.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ccb3f47

Please sign in to comment.