From 6e0c77e738a3bd7365fc8f4abf1170001ecf9d5d Mon Sep 17 00:00:00 2001 From: Jiuzhen Pan <2216991777@qq.com> Date: Sun, 21 Aug 2022 23:54:58 -0700 Subject: [PATCH] refactor(language panel): moved language panel from navbar to sidebar --- components/framework/Sidebar.tsx | 46 +++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 7 deletions(-) diff --git a/components/framework/Sidebar.tsx b/components/framework/Sidebar.tsx index 9126f90..b48ef63 100644 --- a/components/framework/Sidebar.tsx +++ b/components/framework/Sidebar.tsx @@ -1,11 +1,19 @@ -import { BookOpenIcon, ViewGridIcon } from "@heroicons/react/solid"; -import { useTranslation } from "next-i18next"; +import { Menu } from "@fluid-design/fluid-ui"; +import { + BookOpenIcon, + ViewGridIcon, + ChevronUpIcon, + GlobeIcon, +} from "@heroicons/react/solid"; +import { i18n, useTranslation } from "next-i18next"; import Link from "next/link"; import { useRouter } from "next/router"; import clsxm from "../../lib/clsxm"; +import { languages } from "../../lib/languages"; import packageInfo from "../../package.json"; import AppLogo from "../ui/AppLogo"; +import UnstyledLink from "./UnstyledLink"; const navigation = [ { name: "Examples", href: "examples", icon: ViewGridIcon }, @@ -59,20 +67,24 @@ const secondaryNavigation = [ export const SidebarMenu = () => { const router = useRouter(); - const activeTab = router?.pathname?.split("/")?.pop(); + const { pathname, asPath, query } = router; + const activeTab = pathname?.split("/")?.pop(); const { t } = useTranslation(); return (
-
+
Fluid Design -
-

Fluid Design

+ +
Fluid Design
V{packageInfo.version}
-
+
))} + ({ + label: name, + icon: , + role: "default", + disabled: code === i18n?.language, + sr: t("switch-language", { ns: "navbar", name }), + onClick: () => + router.push({ pathname, query }, asPath, { + locale: code, + }), + }))} + />