feat(layout): add shared badge

This commit is contained in:
Elian Doran
2025-12-09 21:44:39 +02:00
parent f42031c8de
commit 644d051477
3 changed files with 35 additions and 14 deletions

View File

@@ -3,11 +3,13 @@ import "./BreadcrumbBadges.css";
import { ComponentChildren } from "preact";
import { useIsNoteReadOnly, useNoteContext } from "./react/hooks";
import Icon from "./react/Icon";
import { useShareInfo } from "./shared_info";
export default function NoteBadges() {
return (
<div className="breadcrumb-badges">
<ReadOnlyBadge />
<ShareBadge />
</div>
);
}
@@ -26,6 +28,19 @@ function ReadOnlyBadge() {
);
}
function ShareBadge() {
const { note } = useNoteContext();
const { isSharedExternally, link } = useShareInfo(note);
return (link &&
<Badge
icon={isSharedExternally ? "bx bx-world" : "bx bx-link"}
>
{isSharedExternally ? "Shared publicly" : "Shared locally"}
</Badge>
);
}
function Badge({ icon, children, onClick }: { icon: string, children: ComponentChildren, onClick?: () => void }) {
return (
<div className="breadcrumb-badge" onClick={onClick}>