Skip to content

Commit

Permalink
Remove language switcher from mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
luisdralves committed Dec 13, 2023
1 parent 81e0553 commit c421d39
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 309 deletions.

This file was deleted.

This file was deleted.

84 changes: 2 additions & 82 deletions workspaces/website/src/components/Layout/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,20 @@
import { useCallback, useState, useEffect } from "react";
import {
Box,
Drawer,
DrawerBody,
DrawerContent,
DrawerHeader,
DrawerOverlay,
Stack,
HStack,
useColorMode,
useColorModeValue,
useDisclosure,
Icon,
} from "@chakra-ui/react";
import { Heading } from "@ui/Typography/Heading";
import { Text } from "@ui/Typography/Text";
import { ColumnLink, ColumnLinkDescription } from "@ui/ColumnLink/ColumnLink";
import { i18nConfig } from "@starknet-io/cms-data/src/i18n/config";
import * as React from "react";
import { HiGlobeAlt, HiOutlineMoon, HiOutlineSun } from "react-icons/hi2";
import { HiOutlineMoon, HiOutlineSun } from "react-icons/hi2";
import { Button } from "../../Button";
import { NavLayout } from "./NavLayout";
import MobileLanguagesDrawer from "./MobileLanguagesDrawer";
import { usePageContext } from "src/renderer/PageContextProvider";
import { SEOTexts } from "@starknet-io/cms-data/src/seo";

Expand Down Expand Up @@ -49,15 +42,7 @@ export const NavBar = ({
const { isOpen, onOpen, onClose } = useDisclosure();
const menuButtonRef = React.useRef<HTMLButtonElement>(null);
const { colorMode, toggleColorMode } = useColorMode();
const [isLanguagesDrawerOpen, setLanguagesDrawerOpen] = useState(false);
const onLanguagesDrawerClose = useCallback(() => {
setLanguagesDrawerOpen(false);
onOpen();
}, []);
const onLanguagesDrawerOpen = useCallback(() => setLanguagesDrawerOpen(true), []);
const { locale, urlPathname: pathname } = usePageContext();
const localeConfig = i18nConfig.find((c) => c.code === locale)!;
const topLanguages = ["en", "es", "fr", "de", "pt", "ar", "ja", "ko"];
const { urlPathname: pathname } = usePageContext();

React.useEffect(() => {
onClose();
Expand All @@ -73,14 +58,6 @@ export const NavBar = ({
}
}

const openLanguageDrawer = () => {
onLanguagesDrawerOpen();
}

useEffect(() => {
isLanguagesDrawerOpen && onClose();
}, [isLanguagesDrawerOpen])

return (
<Box as="nav" bg="navbar-bg" boxShadow={useColorModeValue("xs", "sm-dark")}>
<NavLayout
Expand Down Expand Up @@ -134,66 +111,9 @@ export const NavBar = ({
>
{colorMode === "light" ? "Dark" : "Light"} mode
</Button>
<Button
flex="1"
height="100%"
fontWeight="semibold"
size="lg"
variant="ghost"
leftIcon={<Icon as={HiGlobeAlt} fontSize="xl" />}
onClick={openLanguageDrawer}
>
Languages
</Button>
</HStack>
</DrawerContent>
</Drawer>
<MobileLanguagesDrawer search={search} isOpen={isLanguagesDrawerOpen} onClose={onLanguagesDrawerClose}>
<Heading
color="heading-navy-fg"
variant="h6"
mb={5}
mt={5}
textTransform="uppercase"
>Languages</Heading>
{i18nConfig
.filter((c) => topLanguages.includes(c.code))
.map((c, i) => {
return (
<HStack key={i}>
<ColumnLink
active={localeConfig.code === c.code}
href={`/${c.code}${pathname.replace(/^\/\w{2}($|\/)/, "/")}`}
>
{c.name}
</ColumnLink>
<ColumnLinkDescription active={localeConfig.code === c.code}>
{c.localName}
</ColumnLinkDescription>
</HStack>
);
})}
<Stack spacing="1" pb={4} pt={10} mt={8} borderTopWidth="1px" borderTopStyle="solid" borderColor="btn-outline-border">
<Heading
color="heading-navy-fg"
variant="h6"
textTransform="uppercase"
mb={5}
>
{seo.subtitle}
</Heading>

<Text variant="cardBody">{seo.description}</Text>
<Box height="32px" />
<Button
as="a"
variant="outline"
href="/en/community/language-support"
>
{seo.callToAction}
</Button>
</Stack>
</MobileLanguagesDrawer>
</Box>
</Box>
);
Expand Down
47 changes: 0 additions & 47 deletions workspaces/website/src/pages/(components)/LocaleSwitcher.tsx

This file was deleted.

0 comments on commit c421d39

Please sign in to comment.