Skip to content

Build your personal knowledge base with Trilium Notes

feat(web-clipper): make the popup's footer the one place for the connection

Elian Doran7b934321ad48
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html
index 5482fc9365..cb6c6acfab 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Installation & Setup/Web Clipper.html
@@ -30,10 +30,7 @@
<h2>The popup</h2>
<p>Clicking the extension's button in the browser toolbar opens its popup:</p>
<ul>
- <li>The header shows whether the extension is connected to Trilium, as a colored
- dot (green when connected, amber when the versions are not compatible,
- red when Trilium was not found), next to the buttons for the extension's
- options and for this help page.</li>
+ <li>The header has buttons for the extension's options and for this help page.</li>
<li>The popup reads the current page as an article and shows a preview of
what will be saved: the note's title, which can be edited before saving,
the website and the publication date (when the page states one), and the
@@ -54,8 +51,11 @@
open the note in Trilium.</li>
<li>If Trilium cannot be found, the popup explains why instead of showing
the actions, with buttons to look for Trilium again and to open the options.</li>
- <li>The bottom of the popup describes the connection, with a button to check
- it again.</li>
+ <li>The bottom of the popup shows whether the extension is connected to Trilium,
+ as a colored dot (green when connected, amber when the versions are not
+ compatible, red when Trilium was not found) next to a description of the
+ connection. A button to check the connection again appears when hovering
+ over it, and stays visible while Trilium cannot be reached or is not compatible.</li>
</ul>
<h2>Location of clippings</h2>
<p>Trilium will save these clippings as a new child note under a "clipper
diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsx
index ed3faa698c..0f60cb75ec 100644
--- a/apps/web-clipper/entrypoints/popup/main.tsx
+++ b/apps/web-clipper/entrypoints/popup/main.tsx
@@ -105,7 +105,6 @@ export function Popup() {
<div className="popup-header">
<img className="logo" src="/icons/48.png" alt="" />
<h3>Trilium Web Clipper</h3>
- <span className={`status-dot status-dot-${status.kind}`} title={status.text} />
<div className="popup-header-buttons">
<button className="icon-action" title="Options" aria-label="Options" onClick={() => browser.runtime.openOptionsPage()}>
@@ -141,7 +140,10 @@ export function Popup() {
{body}
<div className="connection">
- <span className={`status-${status.kind}`} title={status.title}>{status.text}</span>
+ <span className={`status-${status.kind}`} title={status.title}>
+ <span className={`status-dot status-dot-${status.kind}`} />
+ {status.text}
+ </span>
<button
className="icon-action"
diff --git a/apps/web-clipper/entrypoints/popup/popup.css b/apps/web-clipper/entrypoints/popup/popup.css
index 039fc176aa..486fe9735c 100644
--- a/apps/web-clipper/entrypoints/popup/popup.css
+++ b/apps/web-clipper/entrypoints/popup/popup.css
@@ -30,30 +30,6 @@ body {
margin-inline-start: auto;
}
- .status-dot {
- flex-shrink: 0;
- width: 8px;
- height: 8px;
- border-radius: 50%;
- }
-
- .status-dot-pending {
- background: var(--muted-text-color);
- opacity: 0.5;
- }
-
- .status-dot-ok {
- background: var(--status-ok-color);
- }
-
- .status-dot-warning {
- background: var(--status-warning-color);
- }
-
- .status-dot-error {
- background: var(--status-error-color);
- }
-
.callout {
padding: 8px 10px;
border-radius: 6px;
@@ -274,21 +250,50 @@ body {
align-items: center;
justify-content: space-between;
gap: 8px;
- padding-top: 8px;
+ min-height: 26px;
+ margin: 0 -12px -12px;
+ padding: 4px 12px;
border-top: 1px solid var(--main-border-color);
color: var(--muted-text-color);
--icon-button-size: 26px;
- }
- .status-ok {
- color: var(--status-ok-color);
- }
+ > span {
+ display: flex;
+ align-items: center;
+ gap: 6px;
+ min-width: 0;
+ }
- .status-warning {
- color: var(--status-warning-color);
- }
+ .status-dot {
+ flex-shrink: 0;
+ width: 8px;
+ height: 8px;
+ border-radius: 50%;
+ }
+
+ .status-dot-pending {
+ background: var(--muted-text-color);
+ opacity: 0.5;
+ }
+
+ .status-dot-ok {
+ background: var(--status-ok-color);
+ }
+
+ .status-dot-warning {
+ background: var(--status-warning-color);
+ }
+
+ .status-dot-error {
+ background: var(--status-error-color);
+ }
+
+ .icon-action {
+ transition: opacity 150ms ease-out;
+ }
- .status-error {
- color: var(--status-error-color);
+ &:has(.status-ok, .status-pending):not(:hover, :focus-within) .icon-action {
+ opacity: 0;
+ }
}
}
diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsx
index 1e1f1ae2d6..449b9696db 100644
--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx
+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx
@@ -54,10 +54,11 @@ describe("popup", () => {
vi.restoreAllMocks();
});
- it("asks for the connection status and shows it in the header and the footer", async () => {
+ it("asks for the connection status and shows it in the footer", async () => {
expect(sendMessage).toHaveBeenCalledWith({ name: "send-trilium-search-status" });
expect(status()).toEqual({ dot: "status-dot status-dot-pending", text: "Looking for Trilium…" });
expect(captureButtons()).toHaveLength(5);
+ expect(container.querySelector(".popup-header .status-dot")).toBeNull();
expect(captureButtons().every((button) => !button.disabled)).toBe(true);
await receive({ name: "trilium-search-status", triliumSearch: { status: "found-desktop", port: 37840, url: "" } });
@@ -468,7 +469,7 @@ function captureButtons() {
function status() {
return {
- dot: container.querySelector<HTMLElement>(".status-dot")?.className,
+ dot: container.querySelector<HTMLElement>(".connection > span > .status-dot")?.className,
text: container.querySelector(".connection > span")?.textContent
};
}
diff --git a/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md b/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md
index dd9d956d11..dc5fddd0f3 100644
--- a/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md
+++ b/docs/User Guide/User Guide/Installation & Setup/Web Clipper.md
@@ -29,13 +29,13 @@ The extension is available from the official browser web stores:
Clicking the extension's button in the browser toolbar opens its popup:
-* The header shows whether the extension is connected to Trilium, as a colored dot (green when connected, amber when the versions are not compatible, red when Trilium was not found), next to the buttons for the extension's options and for this help page.
+* The header has buttons for the extension's options and for this help page.
* The popup reads the current page as an article and shows a preview of what will be saved: the note's title, which can be edited before saving, the website and the publication date (when the page states one), and the article's text and images. _Save page to Trilium_ saves it. Pages the extension cannot read, such as the browser's own pages, say so instead. The keyboard shortcut and the context menu still save the page right away, without a preview.
* Below the preview, a row of buttons offers the other actions: _Crop_ (a screenshot of an area you select), _Screenshot_ (of the visible part of the page), _Note_ (a link with a note) and _Tabs_ (saves the links of every tab in the current window as a list). Hovering over a button shows its full name and, if it has one, its keyboard shortcut.
* _Note_ opens a small editor in place of the actions. The first sentence or line of the text becomes the note's title, unless _Keep page title as note title_ is checked. Press _Save_ or <kbd>Ctrl</kbd>+<kbd>Enter</kbd> to save it, or the back arrow to return to the actions.
* If the current page was already clipped, a notice at the top offers to open the note in Trilium.
* If Trilium cannot be found, the popup explains why instead of showing the actions, with buttons to look for Trilium again and to open the options.
-* The bottom of the popup describes the connection, with a button to check it again.
+* The bottom of the popup shows whether the extension is connected to Trilium, as a colored dot (green when connected, amber when the versions are not compatible, red when Trilium was not found) next to a description of the connection. A button to check the connection again appears when hovering over it, and stays visible while Trilium cannot be reached or is not compatible.
## Location of clippings