mirror of
https://github.com/Shadowfita/docmost.git
synced 2025-11-09 20:12:00 +10:00
* feat: support i18n * feat: wip support i18n * feat: complete space translation * feat: complete page translation * feat: update space translation * feat: update workspace translation * feat: update group translation * feat: update workspace translation * feat: update page translation * feat: update user translation * chore: update pnpm-lock * feat: add query translation * refactor: merge to single file * chore: remove necessary code * feat: save language to BE * fix: only load current language * feat: save language to locale column * fix: cleanups * add language menu to preferences page * new translations * translate editor * Translate editor placeholders * translate space selection component --------- Co-authored-by: Philip Okugbe <phil@docmost.com> Co-authored-by: Philip Okugbe <16838612+Philipinho@users.noreply.github.com>
85 lines
2.4 KiB
TypeScript
85 lines
2.4 KiB
TypeScript
import {Group, Text, Tooltip} from "@mantine/core";
|
|
import classes from "./app-header.module.css";
|
|
import React from "react";
|
|
import TopMenu from "@/components/layouts/global/top-menu.tsx";
|
|
import {Link} from "react-router-dom";
|
|
import APP_ROUTE from "@/lib/app-route.ts";
|
|
import {useAtom} from "jotai/index";
|
|
import {
|
|
desktopSidebarAtom,
|
|
mobileSidebarAtom,
|
|
} from "@/components/layouts/global/hooks/atoms/sidebar-atom.ts";
|
|
import {useToggleSidebar} from "@/components/layouts/global/hooks/hooks/use-toggle-sidebar.ts";
|
|
import SidebarToggle from "@/components/ui/sidebar-toggle-button.tsx";
|
|
import { useTranslation } from "react-i18next";
|
|
|
|
const links = [{link: APP_ROUTE.HOME, label: "Home"}];
|
|
|
|
export function AppHeader() {
|
|
const { t } = useTranslation();
|
|
const [mobileOpened] = useAtom(mobileSidebarAtom);
|
|
const toggleMobile = useToggleSidebar(mobileSidebarAtom);
|
|
|
|
const [desktopOpened] = useAtom(desktopSidebarAtom);
|
|
const toggleDesktop = useToggleSidebar(desktopSidebarAtom);
|
|
|
|
const isHomeRoute = location.pathname.startsWith("/home");
|
|
|
|
const items = links.map((link) => (
|
|
<Link key={link.label} to={link.link} className={classes.link}>
|
|
{t(link.label)}
|
|
</Link>
|
|
));
|
|
|
|
return (
|
|
<>
|
|
<Group h="100%" px="md" justify="space-between" wrap={"nowrap"}>
|
|
<Group wrap="nowrap">
|
|
{!isHomeRoute && (
|
|
<>
|
|
<Tooltip label={t("Sidebar toggle")}>
|
|
|
|
<SidebarToggle
|
|
aria-label={t("Sidebar toggle")}
|
|
opened={mobileOpened}
|
|
onClick={toggleMobile}
|
|
hiddenFrom="sm"
|
|
size="sm"
|
|
/>
|
|
</Tooltip>
|
|
|
|
<Tooltip label={t("Sidebar toggle")}>
|
|
<SidebarToggle
|
|
aria-label={t("Sidebar toggle")}
|
|
opened={desktopOpened}
|
|
onClick={toggleDesktop}
|
|
visibleFrom="sm"
|
|
size="sm"
|
|
/>
|
|
</Tooltip>
|
|
</>
|
|
)}
|
|
|
|
<Text
|
|
size="lg"
|
|
fw={600}
|
|
style={{cursor: "pointer", userSelect: "none"}}
|
|
component={Link}
|
|
to="/home"
|
|
>
|
|
Docmost
|
|
</Text>
|
|
|
|
<Group ml={50} gap={5} className={classes.links} visibleFrom="sm">
|
|
{items}
|
|
</Group>
|
|
</Group>
|
|
|
|
<Group px={"xl"}>
|
|
<TopMenu/>
|
|
</Group>
|
|
</Group>
|
|
</>
|
|
);
|
|
}
|