Skip to content

Build your personal knowledge base with Trilium Notes

feat(web-clipper): show the popup's notices as a banner across its top

Elian Doranf3dc6d7a687f
diff --git a/apps/web-clipper/assets/theme.css b/apps/web-clipper/assets/theme.css
index 20ff70bf72..2edd48d3bd 100644
--- a/apps/web-clipper/assets/theme.css
+++ b/apps/web-clipper/assets/theme.css
@@ -70,6 +70,10 @@
--status-warning-color: #b7bd10;
--status-error-color: #b32323;
+ /* The text editor's admonition accents, which the app uses for its notices in both themes. */
+ --admonition-note-accent-color: #69c7ff;
+ --admonition-warning-accent-color: #e2aa03;
+
/* Bootstrap's default, which the Next theme's text boxes are rounded by. */
--bs-border-radius: 0.375rem;
}
diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsx
index ab6c86c418..c1621b9050 100644
--- a/apps/web-clipper/entrypoints/popup/main.tsx
+++ b/apps/web-clipper/entrypoints/popup/main.tsx
@@ -84,6 +84,7 @@ export function Popup() {
}, []);
const status = describeStatus(searchStatus);
+ const isMismatch = searchStatus?.status === "version-mismatch";
let body: ComponentChildren;
if (isWritingNote) {
@@ -102,24 +103,27 @@ export function Popup() {
return (
<div className="popup">
- {clippedNoteId && (
- <div className="callout callout-info already-visited">
- <span>Web page already clipped.</span>
- <a
- href="#"
- onClick={(e) => {
- e.preventDefault();
- void sendMessage({ name: "openNoteInTrilium", noteId: clippedNoteId });
- }}
- >Open in Trilium</a>
- </div>
- )}
-
- {searchStatus?.status === "version-mismatch" && (
- <div className="callout callout-warning">
- Trilium instance found, but it is not compatible with this extension version.
- Please update {searchStatus.extensionMajor > searchStatus.triliumMajor ? "Trilium Notes" : "this extension"} to
- the latest version.
+ {(clippedNoteId || isMismatch) && (
+ <div className="notices">
+ {clippedNoteId && (
+ <div className="callout callout-info already-visited">
+ <span>Web page already clipped.</span>
+ <a
+ href="#"
+ onClick={(e) => {
+ e.preventDefault();
+ void sendMessage({ name: "openNoteInTrilium", noteId: clippedNoteId });
+ }}
+ >Open in Trilium</a>
+ </div>
+ )}
+ {searchStatus?.status === "version-mismatch" && (
+ <div className="callout callout-warning">
+ Trilium instance found, but it is not compatible with this extension version.
+ Please update {searchStatus.extensionMajor > searchStatus.triliumMajor ? "Trilium Notes" : "this extension"} to
+ the latest version.
+ </div>
+ )}
</div>
)}
diff --git a/apps/web-clipper/entrypoints/popup/popup.css b/apps/web-clipper/entrypoints/popup/popup.css
index e2a953acfa..df06bf29bf 100644
--- a/apps/web-clipper/entrypoints/popup/popup.css
+++ b/apps/web-clipper/entrypoints/popup/popup.css
@@ -8,9 +8,13 @@ body {
gap: 12px;
padding: 12px;
+ .notices {
+ margin: -12px -12px 0;
+ box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
+ }
+
.callout {
- padding: 8px 10px;
- border-radius: 6px;
+ padding: 10px 12px;
}
.callout-info {
@@ -18,11 +22,18 @@ body {
align-items: center;
justify-content: space-between;
gap: 8px;
- background: var(--link-hover-background);
+ background: color-mix(in srgb, var(--admonition-note-accent-color) 15%, var(--main-background-color));
+
+ a {
+ flex-shrink: 0;
+ margin: -4px -8px;
+ padding: 4px 8px;
+ border-radius: 6px;
+ }
}
.callout-warning {
- background: color-mix(in srgb, var(--status-warning-color) 18%, transparent);
+ background: color-mix(in srgb, var(--admonition-warning-accent-color) 15%, var(--main-background-color));
}
.capture-actions {
diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsx
index 821c96de31..511d748140 100644
--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx
+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx
@@ -99,7 +99,8 @@ describe("popup", () => {
triliumSearch: { status: "version-mismatch", extensionMajor: 2, triliumMajor: 1 }
});
expect(status()).toEqual({ dot: "status-dot status-dot-warning", text: "Incompatible version" });
- expect(container.querySelector(".callout-warning")?.textContent).toContain("Please update Trilium Notes");
+ expect(container.querySelector(".popup > .notices:first-child > .callout-warning")?.textContent)
+ .toContain("Please update Trilium Notes");
expect(captureButtons().every((button) => !button.disabled)).toBe(true);
await receive({
@@ -127,7 +128,8 @@ describe("popup", () => {
expect(container.querySelector(".already-visited")).toBeNull();
await receive({ name: "trilium-previously-visited", searchNote: { status: "found", noteId: "clipped" } });
- expect(container.querySelector(".already-visited span")?.textContent).toBe("Web page already clipped.");
+ expect(container.querySelector(".popup > .notices:first-child > .already-visited span")?.textContent)
+ .toBe("Web page already clipped.");
const link = container.querySelector<HTMLAnchorElement>(".already-visited a");
expect(link?.textContent).toBe("Open in Trilium");
@@ -136,6 +138,7 @@ describe("popup", () => {
await receive({ name: "trilium-previously-visited", searchNote: { status: "not-found", noteId: null } });
expect(container.querySelector(".already-visited")).toBeNull();
+ expect(container.querySelector(".notices")).toBeNull();
});
it("sends the capture actions, closing the popup for screenshots", async () => {