mirror of
https://github.com/zadam/trilium.git
synced 2025-12-20 22:34:23 +01:00
feat(breadcrumb): respect note color
This commit is contained in:
parent
2693b18ee6
commit
0af5fa9f0c
@ -26,7 +26,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
a {
|
a {
|
||||||
color: inherit;
|
color: var(--custom-color, inherit);
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
min-width: 0;
|
min-width: 0;
|
||||||
max-width: 150px;
|
max-width: 150px;
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { HTMLAttributes } from "preact";
|
|||||||
import { useEffect, useRef, useState } from "preact/hooks";
|
import { useEffect, useRef, useState } from "preact/hooks";
|
||||||
|
|
||||||
import link, { calculateHash, ViewScope } from "../../services/link";
|
import link, { calculateHash, ViewScope } from "../../services/link";
|
||||||
import { useImperativeSearchHighlighlighting, useNote, useNoteIcon, useNoteProperty, useTriliumEvent } from "./hooks";
|
import { useImperativeSearchHighlighlighting, useNote, useNoteColorClass, useNoteIcon, useNoteProperty, useTriliumEvent } from "./hooks";
|
||||||
import Icon from "./Icon";
|
import Icon from "./Icon";
|
||||||
|
|
||||||
interface NoteLinkOpts {
|
interface NoteLinkOpts {
|
||||||
@ -100,6 +100,7 @@ export function NewNoteLink({ notePath, viewScope, noContextMenu, showNoteIcon,
|
|||||||
const note = useNote(noteId);
|
const note = useNote(noteId);
|
||||||
const title = useNoteProperty(note, "title");
|
const title = useNoteProperty(note, "title");
|
||||||
const icon = useNoteIcon(showNoteIcon ? note : null);
|
const icon = useNoteIcon(showNoteIcon ? note : null);
|
||||||
|
const colorClass = useNoteColorClass(note);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span>
|
<span>
|
||||||
@ -107,7 +108,7 @@ export function NewNoteLink({ notePath, viewScope, noContextMenu, showNoteIcon,
|
|||||||
{icon && <Icon icon={icon} />}
|
{icon && <Icon icon={icon} />}
|
||||||
|
|
||||||
<a
|
<a
|
||||||
className={clsx("tn-link", {
|
className={clsx("tn-link", colorClass, {
|
||||||
"no-tooltip-preview": noPreview
|
"no-tooltip-preview": noPreview
|
||||||
})}
|
})}
|
||||||
href={calculateHash({ notePath, viewScope })}
|
href={calculateHash({ notePath, viewScope })}
|
||||||
|
|||||||
@ -1061,3 +1061,12 @@ export function useNoteIcon(note: FNote | null | undefined) {
|
|||||||
|
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function useNoteColorClass(note: FNote | null | undefined) {
|
||||||
|
const [ colorClass, setColorClass ] = useState(note?.getColorClass());
|
||||||
|
const [ color ] = useNoteLabel(note, "color");
|
||||||
|
useEffect(() => {
|
||||||
|
setColorClass(note?.getColorClass());
|
||||||
|
}, [ color, note ]);
|
||||||
|
return colorClass;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user