feat: add changing appearance for guests (#2632)

* Allow changing appearance when guest

* Apply suggestions from code review

Co-authored-by: Tom Moor <tom.moor@gmail.com>
This commit is contained in:
Alexander Krantz
2021-10-07 18:43:41 -07:00
committed by GitHub
parent ccd947c6e8
commit 09a409b494

View File

@ -4,7 +4,9 @@ import {
TableOfContentsIcon, TableOfContentsIcon,
EditIcon, EditIcon,
PlusIcon, PlusIcon,
MoonIcon,
MoreIcon, MoreIcon,
SunIcon,
} from "outline-icons"; } from "outline-icons";
import * as React from "react"; import * as React from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@ -70,6 +72,7 @@ function DocumentHeader({
const { t } = useTranslation(); const { t } = useTranslation();
const team = useCurrentTeam(); const team = useCurrentTeam();
const { ui, policies } = useStores(); const { ui, policies } = useStores();
const { resolvedTheme } = ui;
const isMobile = useMobile(); const isMobile = useMobile();
const handleSave = React.useCallback(() => { const handleSave = React.useCallback(() => {
@ -125,6 +128,27 @@ function DocumentHeader({
</Action> </Action>
); );
const appearanceAction = (
<Action>
<Tooltip
tooltip={
resolvedTheme === "light" ? t("Switch to dark") : t("Switch to light")
}
delay={500}
placement="bottom"
>
<Button
icon={resolvedTheme === "light" ? <SunIcon /> : <MoonIcon />}
onClick={() =>
ui.setTheme(resolvedTheme === "light" ? "dark" : "light")
}
neutral
borderOnHover
/>
</Tooltip>
</Action>
);
if (shareId) { if (shareId) {
return ( return (
<Header <Header
@ -138,7 +162,12 @@ function DocumentHeader({
{toc} {toc}
</PublicBreadcrumb> </PublicBreadcrumb>
} }
actions={canEdit ? editAction : <div />} actions={
<>
{appearanceAction}
{canEdit ? editAction : <div />}
</>
}
/> />
); );
} }