feat(web): add demo mode banner (#5836)
This commit is contained in:
parent
101704c8ea
commit
35504cc8bd
5 changed files with 39 additions and 6 deletions
|
|
@ -13,11 +13,8 @@ import { Routes } from "@/router";
|
||||||
const ARCHIVED_ROUTE = "/archived";
|
const ARCHIVED_ROUTE = "/archived";
|
||||||
const PROFILE_ROUTE = "/u/:username";
|
const PROFILE_ROUTE = "/u/:username";
|
||||||
const DESKTOP_EXPLORER_WIDTH_CLASS = "w-64";
|
const DESKTOP_EXPLORER_WIDTH_CLASS = "w-64";
|
||||||
const DESKTOP_EXPLORER_CLASS_NAME = cn(
|
const DESKTOP_EXPLORER_CLASS_NAME = cn("sticky top-0 h-svh shrink-0 border-r border-border transition-all", DESKTOP_EXPLORER_WIDTH_CLASS);
|
||||||
"fixed top-0 left-16 h-svh shrink-0 border-r border-border transition-all",
|
const MAIN_CONTENT_CLASS_NAME = "w-full min-h-full min-w-0 flex-1";
|
||||||
DESKTOP_EXPLORER_WIDTH_CLASS,
|
|
||||||
);
|
|
||||||
const MAIN_CONTENT_CLASS_NAME = cn("w-full min-h-full", "md:pl-64");
|
|
||||||
|
|
||||||
const MainLayout = () => {
|
const MainLayout = () => {
|
||||||
const md = useMediaQuery("md");
|
const md = useMediaQuery("md");
|
||||||
|
|
@ -71,7 +68,7 @@ const MainLayout = () => {
|
||||||
const memoExplorerProps = { context, statisticsData: statistics, tagCount: tags };
|
const memoExplorerProps = { context, statisticsData: statistics, tagCount: tags };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="@container w-full min-h-full flex flex-col justify-start items-center">
|
<section className="@container w-full min-h-full flex flex-col justify-start items-center md:flex-row md:items-start">
|
||||||
{!md && (
|
{!md && (
|
||||||
<MobileHeader>
|
<MobileHeader>
|
||||||
<MemoExplorerDrawer {...memoExplorerProps} />
|
<MemoExplorerDrawer {...memoExplorerProps} />
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { useEffect, useMemo } from "react";
|
||||||
import { Outlet, useLocation, useSearchParams } from "react-router-dom";
|
import { Outlet, useLocation, useSearchParams } from "react-router-dom";
|
||||||
import usePrevious from "react-use/lib/usePrevious";
|
import usePrevious from "react-use/lib/usePrevious";
|
||||||
import Navigation from "@/components/Navigation";
|
import Navigation from "@/components/Navigation";
|
||||||
|
import { useInstance } from "@/contexts/InstanceContext";
|
||||||
import { useMemoFilterContext } from "@/contexts/MemoFilterContext";
|
import { useMemoFilterContext } from "@/contexts/MemoFilterContext";
|
||||||
import useCurrentUser from "@/hooks/useCurrentUser";
|
import useCurrentUser from "@/hooks/useCurrentUser";
|
||||||
import useMediaQuery from "@/hooks/useMediaQuery";
|
import useMediaQuery from "@/hooks/useMediaQuery";
|
||||||
|
|
@ -9,6 +10,25 @@ import useNavigateTo from "@/hooks/useNavigateTo";
|
||||||
import { cn } from "@/lib/utils";
|
import { cn } from "@/lib/utils";
|
||||||
import { ROUTES } from "@/router/routes";
|
import { ROUTES } from "@/router/routes";
|
||||||
import { redirectOnAuthFailure } from "@/utils/auth-redirect";
|
import { redirectOnAuthFailure } from "@/utils/auth-redirect";
|
||||||
|
import { useTranslate } from "@/utils/i18n";
|
||||||
|
|
||||||
|
const MEMOS_DEPLOY_URL = "https://usememos.com/docs/deploy";
|
||||||
|
|
||||||
|
const DemoBanner = () => {
|
||||||
|
const t = useTranslate();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="static w-full border-b border-border bg-muted/70 px-4 py-2 text-sm text-muted-foreground sm:px-6">
|
||||||
|
<div className="mx-auto flex max-w-5xl flex-col items-start gap-1 sm:flex-row sm:items-center sm:justify-center sm:gap-2">
|
||||||
|
<span className="font-medium text-foreground">{t("demo.banner-title")}</span>
|
||||||
|
<span>{t("demo.banner-description")}</span>
|
||||||
|
<a className="font-medium text-primary underline-offset-4 hover:underline" href={MEMOS_DEPLOY_URL} target="_blank" rel="noreferrer">
|
||||||
|
{t("demo.deploy-link")}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const RootLayout = () => {
|
const RootLayout = () => {
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
|
@ -16,6 +36,7 @@ const RootLayout = () => {
|
||||||
const sm = useMediaQuery("sm");
|
const sm = useMediaQuery("sm");
|
||||||
const currentUser = useCurrentUser();
|
const currentUser = useCurrentUser();
|
||||||
const navigateTo = useNavigateTo();
|
const navigateTo = useNavigateTo();
|
||||||
|
const { profile } = useInstance();
|
||||||
const { removeFilter } = useMemoFilterContext();
|
const { removeFilter } = useMemoFilterContext();
|
||||||
const pathname = useMemo(() => location.pathname, [location.pathname]);
|
const pathname = useMemo(() => location.pathname, [location.pathname]);
|
||||||
const prevPathname = usePrevious(pathname);
|
const prevPathname = usePrevious(pathname);
|
||||||
|
|
@ -51,6 +72,7 @@ const RootLayout = () => {
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<main className="w-full h-auto grow shrink flex flex-col justify-start items-center">
|
<main className="w-full h-auto grow shrink flex flex-col justify-start items-center">
|
||||||
|
{profile.demo && <DemoBanner />}
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,11 @@
|
||||||
"sign-in-tip": "Already have an account?",
|
"sign-in-tip": "Already have an account?",
|
||||||
"sign-up-tip": "Don't have an account yet?"
|
"sign-up-tip": "Don't have an account yet?"
|
||||||
},
|
},
|
||||||
|
"demo": {
|
||||||
|
"banner-description": "Changes are temporary and may be reset.",
|
||||||
|
"banner-title": "Memos demo",
|
||||||
|
"deploy-link": "Deploy your Memos"
|
||||||
|
},
|
||||||
"attachment-library": {
|
"attachment-library": {
|
||||||
"actions": {
|
"actions": {
|
||||||
"open": "Open",
|
"open": "Open",
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,11 @@
|
||||||
"sign-in-tip": "已有账户?",
|
"sign-in-tip": "已有账户?",
|
||||||
"sign-up-tip": "还没有账户?"
|
"sign-up-tip": "还没有账户?"
|
||||||
},
|
},
|
||||||
|
"demo": {
|
||||||
|
"banner-description": "这里的改动是临时的,可能会被重置。",
|
||||||
|
"banner-title": "Memos 演示站",
|
||||||
|
"deploy-link": "部署你的 Memos"
|
||||||
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"about": "关于",
|
"about": "关于",
|
||||||
"add": "增加",
|
"add": "增加",
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,10 @@
|
||||||
"sign-in-tip": "已經有帳戶了嗎?",
|
"sign-in-tip": "已經有帳戶了嗎?",
|
||||||
"sign-up-tip": "還沒有帳戶嗎?"
|
"sign-up-tip": "還沒有帳戶嗎?"
|
||||||
},
|
},
|
||||||
|
"demo": {
|
||||||
|
"banner-description": "這裡的改動是暫時的,可能會被重置。",
|
||||||
|
"banner-title": "Memos 演示站"
|
||||||
|
},
|
||||||
"common": {
|
"common": {
|
||||||
"about": "關於",
|
"about": "關於",
|
||||||
"add": "新增",
|
"add": "新增",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue