chore: update button entries (#206)

pull/207/head
boojack 3 years ago committed by GitHub
parent e9ac6affef
commit b0b2776d03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,10 +1,10 @@
import { useEffect, useRef } from "react"; import { useEffect, useRef } from "react";
import * as api from "../helpers/api";
import { locationService, userService } from "../services"; import { locationService, userService } from "../services";
import useI18n from "../hooks/useI18n"; import useI18n from "../hooks/useI18n";
import toastHelper from "./Toast";
import Only from "./common/OnlyWhen"; import Only from "./common/OnlyWhen";
import showAboutSiteDialog from "./AboutSiteDialog"; import showAboutSiteDialog from "./AboutSiteDialog";
import showArchivedMemoDialog from "./ArchivedMemoDialog";
import showResourcesDialog from "./ResourcesDialog";
import "../less/menu-btns-popup.less"; import "../less/menu-btns-popup.less";
interface Props { interface Props {
@ -32,27 +32,16 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
} }
}, [shownStatus]); }, [shownStatus]);
const handlePingBtnClick = () => { const handleResourcesBtnClick = () => {
api showResourcesDialog();
.getSystemStatus()
.then(({ data }) => {
const {
data: { profile },
} = data;
toastHelper.info(JSON.stringify(profile, null, 4));
})
.catch((error) => {
console.error(error);
toastHelper.error(error.response.data.message);
});
}; };
const handleAboutBtnClick = () => { const handleArchivedBtnClick = () => {
showAboutSiteDialog(); showArchivedMemoDialog();
}; };
const handleExploreBtnClick = () => { const handleAboutBtnClick = () => {
locationService.pushHistory("/explore"); showAboutSiteDialog();
}; };
const handleSignOutBtnClick = async () => { const handleSignOutBtnClick = async () => {
@ -69,12 +58,14 @@ const MenuBtnsPopup: React.FC<Props> = (props: Props) => {
return ( return (
<div className={`menu-btns-popup ${shownStatus ? "" : "hidden"}`} ref={popupElRef}> <div className={`menu-btns-popup ${shownStatus ? "" : "hidden"}`} ref={popupElRef}>
<button className="btn action-btn" onClick={handleExploreBtnClick}> <Only when={!userService.isVisitorMode()}>
<span className="icon">👾</span> Explore <button className="btn action-btn" onClick={handleResourcesBtnClick}>
</button> <span className="icon">🌄</span> {t("sidebar.resources")}
<button className="btn action-btn" onClick={handlePingBtnClick}> </button>
<span className="icon">🎯</span> Ping <button className="btn action-btn" onClick={handleArchivedBtnClick}>
</button> <span className="icon">🗂</span> {t("sidebar.archived")}
</button>
</Only>
<button className="btn action-btn" onClick={handleAboutBtnClick}> <button className="btn action-btn" onClick={handleAboutBtnClick}>
<span className="icon">🤠</span> {t("common.about")} <span className="icon">🤠</span> {t("common.about")}
</button> </button>

@ -1,11 +1,9 @@
import { userService } from "../services"; import { locationService, userService } from "../services";
import useI18n from "../hooks/useI18n"; import useI18n from "../hooks/useI18n";
import Icon from "./Icon"; import Icon from "./Icon";
import Only from "./common/OnlyWhen"; import Only from "./common/OnlyWhen";
import showDailyReviewDialog from "./DailyReviewDialog"; import showDailyReviewDialog from "./DailyReviewDialog";
import showSettingDialog from "./SettingDialog"; import showSettingDialog from "./SettingDialog";
import showArchivedMemoDialog from "./ArchivedMemoDialog";
import showResourcesDialog from "./ResourcesDialog";
import UserBanner from "./UserBanner"; import UserBanner from "./UserBanner";
import UsageHeatMap from "./UsageHeatMap"; import UsageHeatMap from "./UsageHeatMap";
import ShortcutList from "./ShortcutList"; import ShortcutList from "./ShortcutList";
@ -15,14 +13,12 @@ import "../less/siderbar.less";
const Sidebar = () => { const Sidebar = () => {
const { t } = useI18n(); const { t } = useI18n();
const handleMyAccountBtnClick = () => { const handleSettingBtnClick = () => {
showSettingDialog(); showSettingDialog();
}; };
const handleResourcesBtnClick = () => {
showResourcesDialog(); const handleExploreBtnClick = () => {
}; locationService.pushHistory("/explore");
const handleArchivedBtnClick = () => {
showArchivedMemoDialog();
}; };
return ( return (
@ -39,14 +35,11 @@ const Sidebar = () => {
<span className="icon">📅</span> {t("sidebar.daily-review")} <span className="icon">📅</span> {t("sidebar.daily-review")}
</button> </button>
<Only when={!userService.isVisitorMode()}> <Only when={!userService.isVisitorMode()}>
<button className="btn action-btn" onClick={handleResourcesBtnClick}> <button className="btn action-btn" onClick={handleSettingBtnClick}>
<span className="icon">🌄</span> {t("sidebar.resources")}
</button>
<button className="btn action-btn" onClick={handleMyAccountBtnClick}>
<span className="icon"></span> {t("sidebar.setting")} <span className="icon"></span> {t("sidebar.setting")}
</button> </button>
<button className="btn action-btn" onClick={handleArchivedBtnClick}> <button className="btn action-btn" onClick={() => handleExploreBtnClick()}>
<span className="icon">🗂</span> {t("sidebar.archived")} <span className="icon">🏂</span> {t("common.explore")}
</button> </button>
</Only> </Only>
</div> </div>

@ -8,10 +8,20 @@
@apply relative w-full min-h-screen mx-auto flex flex-col justify-start items-center; @apply relative w-full min-h-screen mx-auto flex flex-col justify-start items-center;
> .page-header { > .page-header {
@apply relative max-w-2xl w-full min-h-full flex flex-row justify-start items-center px-4 sm:pr-6; @apply relative max-w-2xl w-full min-h-full flex flex-row justify-between items-center px-4 sm:pr-6 mt-6 mb-2;
> .logo-img { > .logo-img {
@apply h-14 w-auto mt-6 mb-2; @apply h-14 w-auto;
}
> .action-button-container {
> .btn {
@apply text-blue-600 py-1 hover:opacity-80;
> .icon {
@apply text-lg mr-1;
}
}
} }
} }
@ -42,17 +52,5 @@
} }
} }
} }
> .addtion-btn-container {
@apply fixed bottom-12 left-1/2 -translate-x-1/2;
> .btn {
@apply bg-blue-600 text-white px-4 py-2 rounded-3xl shadow-2xl hover:opacity-80;
> .icon {
@apply text-lg mr-1;
}
}
}
} }
} }

@ -22,6 +22,7 @@
"archive": "Archive", "archive": "Archive",
"basic": "Basic", "basic": "Basic",
"admin": "Admin", "admin": "Admin",
"explore": "Explore",
"sign-in": "Sign in", "sign-in": "Sign in",
"sign-out": "Sign out", "sign-out": "Sign out",
"back-to-home": "Back to Home" "back-to-home": "Back to Home"

@ -22,6 +22,7 @@
"archive": "归档", "archive": "归档",
"basic": "基础", "basic": "基础",
"admin": "管理员", "admin": "管理员",
"explore": "探索",
"sign-in": "登录", "sign-in": "登录",
"sign-out": "退出登录", "sign-out": "退出登录",
"back-to-home": "回到主页" "back-to-home": "回到主页"

@ -47,6 +47,17 @@ const Explore = () => {
<div className="page-container"> <div className="page-container">
<div className="page-header"> <div className="page-header">
<img className="logo-img" src="/logo-full.webp" alt="" /> <img className="logo-img" src="/logo-full.webp" alt="" />
<div className="action-button-container">
{user ? (
<button className="btn" onClick={() => (window.location.href = "/")}>
<span className="icon">🏠</span> {t("common.back-to-home")}
</button>
) : (
<button className="btn" onClick={() => (window.location.href = "/auth")}>
<span className="icon">👉</span> {t("common.sign-in")}
</button>
)}
</div>
</div> </div>
<main className="memos-wrapper"> <main className="memos-wrapper">
{state.memos.map((memo) => { {state.memos.map((memo) => {
@ -65,18 +76,6 @@ const Explore = () => {
); );
})} })}
</main> </main>
<div className="addtion-btn-container">
{user ? (
<button className="btn" onClick={() => (window.location.href = "/")}>
<span className="icon">🏠</span> {t("common.back-to-home")}
</button>
) : (
<button className="btn" onClick={() => (window.location.href = "/auth")}>
<span className="icon">👉</span> {t("common.sign-in")}
</button>
)}
</div>
</div> </div>
)} )}
</section> </section>

Loading…
Cancel
Save