mirror of
https://github.com/zadam/trilium.git
synced 2025-12-12 18:34:24 +01:00
chore(breadcrumb_badges): fake backlink widget
This commit is contained in:
parent
3262e3490a
commit
66008489c4
@ -2140,6 +2140,10 @@
|
|||||||
"shared_publicly": "Shared publicly",
|
"shared_publicly": "Shared publicly",
|
||||||
"shared_publicly_description": "This note has been published online at {{- link}}, and is publicly accessible.\n\nClick to navigate to the shared note or right click for more options.",
|
"shared_publicly_description": "This note has been published online at {{- link}}, and is publicly accessible.\n\nClick to navigate to the shared note or right click for more options.",
|
||||||
"shared_locally": "Shared locally",
|
"shared_locally": "Shared locally",
|
||||||
"shared_locally_description": "This note is shared on the local network only at {{- link}}.\n\nClick to navigate to the shared note or right click for more options."
|
"shared_locally_description": "This note is shared on the local network only at {{- link}}.\n\nClick to navigate to the shared note or right click for more options.",
|
||||||
|
"backlinks_one": "{{count}} backlink",
|
||||||
|
"backlinks_other": "{{count}} backlinks",
|
||||||
|
"backlinks_description_one": "This note is linked from {{count}} other note.\n\nClick to view the list of backlinks.",
|
||||||
|
"backlinks_description_other": "This note is linked from {{count}} other notes.\n\nClick to view the list of backlinks."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
&.temporarily-editable-badge { --color: #4fa52b; }
|
&.temporarily-editable-badge { --color: #4fa52b; }
|
||||||
&.read-only-badge { --color: #e33f3b; }
|
&.read-only-badge { --color: #e33f3b; }
|
||||||
&.share-badge { --color: #3b82f6; }
|
&.share-badge { --color: #3b82f6; }
|
||||||
|
&.backlinks-badge { color: var(--badge-text-color); }
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: inherit;
|
||||||
|
|||||||
@ -1,18 +1,20 @@
|
|||||||
import "./BreadcrumbBadges.css";
|
import "./BreadcrumbBadges.css";
|
||||||
|
|
||||||
|
import clsx from "clsx";
|
||||||
import { ComponentChildren, MouseEventHandler } from "preact";
|
import { ComponentChildren, MouseEventHandler } from "preact";
|
||||||
|
import { useRef } from "preact/hooks";
|
||||||
|
|
||||||
|
import { t } from "../services/i18n";
|
||||||
import { useIsNoteReadOnly, useNoteContext, useStaticTooltip } from "./react/hooks";
|
import { useIsNoteReadOnly, useNoteContext, useStaticTooltip } from "./react/hooks";
|
||||||
import Icon from "./react/Icon";
|
import Icon from "./react/Icon";
|
||||||
import { useShareInfo } from "./shared_info";
|
import { useShareInfo } from "./shared_info";
|
||||||
import clsx from "clsx";
|
|
||||||
import { t } from "../services/i18n";
|
|
||||||
import { useRef } from "preact/hooks";
|
|
||||||
|
|
||||||
export default function BreadcrumbBadges() {
|
export default function BreadcrumbBadges() {
|
||||||
return (
|
return (
|
||||||
<div className="breadcrumb-badges">
|
<div className="breadcrumb-badges">
|
||||||
<ReadOnlyBadge />
|
<ReadOnlyBadge />
|
||||||
<ShareBadge />
|
<ShareBadge />
|
||||||
|
<BacklinksBadge />
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -63,7 +65,16 @@ function ShareBadge() {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function Badge({ icon, className, children, tooltip, onClick, href }: { icon: string, className: string, tooltip: string, children: ComponentChildren, onClick?: MouseEventHandler<HTMLDivElement>, href?: string }) {
|
function BacklinksBadge() {
|
||||||
|
const count = 1;
|
||||||
|
return (
|
||||||
|
<Badge className="backlinks-badge" icon="bx bx-revision" tooltip={t("breadcrumb_badges.backlinks_description", { count })}>
|
||||||
|
{t("breadcrumb_badges.backlinks", { count })}
|
||||||
|
</Badge>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function Badge({ icon, className, children, tooltip, onClick, href }: { icon?: string, className: string, tooltip: string, children: ComponentChildren, onClick?: MouseEventHandler<HTMLDivElement>, href?: string }) {
|
||||||
const containerRef = useRef<HTMLDivElement>(null);
|
const containerRef = useRef<HTMLDivElement>(null);
|
||||||
useStaticTooltip(containerRef, {
|
useStaticTooltip(containerRef, {
|
||||||
placement: "bottom",
|
placement: "bottom",
|
||||||
@ -74,7 +85,7 @@ function Badge({ icon, className, children, tooltip, onClick, href }: { icon: st
|
|||||||
});
|
});
|
||||||
|
|
||||||
const content = <>
|
const content = <>
|
||||||
<Icon icon={icon} />
|
{icon && <><Icon icon={icon} /> </>}
|
||||||
{children}
|
{children}
|
||||||
</>;
|
</>;
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user