Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
style(web-clipper): draw the popup and options page in the Next theme
Elian Doran301f69ad99b7
diff --git a/apps/web-clipper/assets/theme.css b/apps/web-clipper/assets/theme.cssnew file mode 100644index 0000000000..081b665bf2--- /dev/null+++ b/apps/web-clipper/assets/theme.css@@ -0,0 +1,141 @@+/* The Next theme's buttons, text boxes and check boxes, as the app draws them. */+@import "@triliumnext/client/src/stylesheets/theme-next/forms.css";++/* The app's own font file, matching the face in the client's `theme-next/base.css`. */+@font-face {+ font-family: "Inter";+ src: url("../../client/src/fonts/Inter/Inter-VariableFont_opsz,wght.woff2") format("woff2-variations");+ font-weight: 100 900;+ font-style: normal;+ font-display: swap;+}++/* The colors of `theme-next-light.css` that the stylesheets above read. */+:root {+ color-scheme: light;++ --main-background-color: white;+ --main-text-color: black;+ --main-border-color: #dbdbdb;+ --muted-text-color: #666;++ --link-color: #0076af;+ --link-hover-color: var(--link-color);+ --link-hover-background: #3c7fa017;++ --cmd-button-background-color: #0000000f;+ --cmd-button-text-color: #000000ad;+ --cmd-button-hover-background-color: #00000016;+ --cmd-button-hover-text-color: #000;+ --cmd-button-shadow-color: #00000040;+ --cmd-button-icon-color: black;+ --cmd-button-disabled-opacity: 0.5;++ --input-background-color: #00000012;+ --input-text-color: black;+ --input-placeholder-color: #06060682;+ --input-selection-background: gray;+ --input-selection-text-color: white;+ --input-hover-background: #00000020;+ --input-hover-color: black;+ --input-focus-outline-color: #00000063;+ --input-focus-background: #ffffff80;+ --input-focus-color: #000;++ --radio-checkbox-background: #0000002e;+ --radio-checkbox-hover-background: #0000004f;+ --radio-checkbox-indicator-color: black;++ /* The log status colors, for the connection status. */+ --status-ok-color: #32b323;+ --status-warning-color: #b7bd10;+ --status-error-color: #b32323;++ /* Bootstrap's default, which the Next theme's text boxes are rounded by. */+ --bs-border-radius: 0.375rem;+}++/* The same colors from `theme-next-dark.css`. */+@media (prefers-color-scheme: dark) {+ :root {+ color-scheme: dark;++ --main-background-color: #242424;+ --main-text-color: #ccc;+ --main-border-color: #454545;+ --muted-text-color: #bbb;++ --link-color: #95c3d9;+ --link-hover-background: #75c2e324;++ --cmd-button-background-color: #ffffff28;+ --cmd-button-text-color: #ffffffc2;+ --cmd-button-hover-background-color: #ffffff37;+ --cmd-button-hover-text-color: white;+ --cmd-button-shadow-color: #00000080;+ --cmd-button-icon-color: white;++ --input-background-color: #ffffff12;+ --input-text-color: #ffffffc7;+ --input-placeholder-color: #b7b7b782;+ --input-hover-background: #ffffff1f;+ --input-hover-color: var(--input-text-color);+ --input-focus-outline-color: #ffffff57;+ --input-focus-background: #ffffff1f;+ --input-focus-color: white;++ --radio-checkbox-background: #ffffff30;+ --radio-checkbox-hover-background: #ffffff61;+ --radio-checkbox-indicator-color: white;++ --status-ok-color: #74d369;+ --status-warning-color: #d3c769;+ --status-error-color: #d36969;+ }+}++* {+ box-sizing: border-box;+}++body {+ margin: 0;+ background: var(--main-background-color);+ color: var(--main-text-color);+ font-family: "Inter", sans-serif;+ font-size: 13px;+}++/* Bootstrap's reboot, which the app loads and an extension page does not. */+button,+input,+textarea {+ font: inherit;+}++button.btn {+ cursor: pointer;+ line-height: 1.5;+}++input[type="text"],+input[type="password"],+textarea {+ padding: 4px 8px;+}++a {+ color: var(--link-color);+ border-radius: 4px;+ text-decoration: none;++ &:hover {+ background: var(--link-hover-background);+ color: var(--link-hover-color);+ }+}++h2,+h3 {+ font-weight: 500;+}diff --git a/apps/web-clipper/entrypoints/options/main.tsx b/apps/web-clipper/entrypoints/options/main.tsxindex 50432b7536..ba9120a470 100644--- a/apps/web-clipper/entrypoints/options/main.tsx+++ b/apps/web-clipper/entrypoints/options/main.tsx@@ -1,3 +1,4 @@+import "@/assets/theme.css";import "./options.css";import { render } from "preact";@@ -80,7 +81,7 @@ function DesktopPortForm({ showMessage }: { showMessage: ShowMessage }) {{" "}(normally keep this empty)</p>- <input type="submit" value="Save" />+ <button type="submit" className="btn btn-primary">Save</button></form>);}@@ -194,7 +195,7 @@ function ServerLoginForm({ showMessage, onLoggedIn }: {</tr><tr><th></th>- <td><input type="submit" value="Login to the server instance" /></td>+ <td><button type="submit" className="btn btn-primary">Login to the server instance</button></td></tr></table>diff --git a/apps/web-clipper/entrypoints/options/options.css b/apps/web-clipper/entrypoints/options/options.cssindex e90fa1a7f5..76b40862e6 100644--- a/apps/web-clipper/entrypoints/options/options.css+++ b/apps/web-clipper/entrypoints/options/options.css@@ -1,21 +1,62 @@.options {+ max-width: 640px;+ padding: 8px 20px 20px;+ line-height: 1.5;++ h2 {+ margin: 24px 0 8px;+ font-size: 1.3em;+ }++ p {+ margin: 8px 0;+ }++ code {+ font-size: 0.95em;+ }+.message {- font-weight: bold;+ margin-top: 16px;+ padding: 8px 12px;+ border-radius: 6px;+ background: var(--input-background-color);+ font-weight: 500;}.message-error {- color: red;+ color: var(--status-error-color);}.message-success {- color: green;+ color: var(--status-ok-color);}label[for="trilium-desktop-port"] {- font-weight: bold;+ font-weight: 500;}.desktop-port {+ width: 6em;text-align: right;}++ table {+ border-spacing: 0 8px;+ }++ th {+ padding-inline-end: 12px;+ font-weight: 500;+ text-align: start;+ white-space: nowrap;+ }++ td {+ color: var(--muted-text-color);+ }++ td > input:not(.desktop-port) {+ width: 220px;+ }}diff --git a/apps/web-clipper/entrypoints/popup/main.tsx b/apps/web-clipper/entrypoints/popup/main.tsxindex 0dda05aae0..e7a6de47e7 100644--- a/apps/web-clipper/entrypoints/popup/main.tsx+++ b/apps/web-clipper/entrypoints/popup/main.tsx@@ -1,3 +1,4 @@+import "@/assets/theme.css";import "./popup.css";import { render } from "preact";@@ -63,8 +64,8 @@ export function Popup() {<h3>Trilium Web Clipper</h3><div className="popup-header-buttons">- <button className="button" onClick={() => browser.runtime.openOptionsPage()}>Options</button>- <button className="button" onClick={() => window.open(HELP_URL, "_blank")}>Help</button>+ <button className="btn btn-sm" onClick={() => browser.runtime.openOptionsPage()}>Options</button>+ <button className="btn btn-sm" onClick={() => window.open(HELP_URL, "_blank")}>Help</button></div></div>@@ -83,30 +84,32 @@ export function Popup() {)}</div>- <button className="button full" {...needsConnection} onClick={() => sendAndClose("save-cropped-screenshot")}>- Crop screenshot- </button>- <button className="button full" {...needsConnection} onClick={() => sendAndClose("save-whole-screenshot")}>- Save whole screenshot- </button>- <button className="button full" {...needsConnection} onClick={() => sendMessage({ name: "save-whole-page" })}>- Save whole page- </button>- <button className="button full" {...needsConnection} onClick={() => setIsWritingNote(true)}>- Save link with a note- </button>- <button className="button full" {...needsConnection} onClick={() => sendMessage({ name: "save-tabs" })}>- Save window's tabs as a list- </button>+ <div className="capture-buttons">+ <button className="btn btn-secondary" {...needsConnection} onClick={() => sendAndClose("save-cropped-screenshot")}>+ Crop screenshot+ </button>+ <button className="btn btn-secondary" {...needsConnection} onClick={() => sendAndClose("save-whole-screenshot")}>+ Save whole screenshot+ </button>+ <button className="btn btn-secondary" {...needsConnection} onClick={() => sendMessage({ name: "save-whole-page" })}>+ Save whole page+ </button>+ <button className="btn btn-secondary" {...needsConnection} onClick={() => setIsWritingNote(true)}>+ Save link with a note+ </button>+ <button className="btn btn-secondary" {...needsConnection} onClick={() => sendMessage({ name: "save-tabs" })}>+ Save window's tabs as a list+ </button>+ </div>{isWritingNote && <LinkWithNoteForm onCancel={() => setIsWritingNote(false)} />}<div className="connection">- <button className="button check-connection-button" onClick={() => sendMessage({ name: "trigger-trilium-search" })}>+ <div>Status: <ConnectionStatus status={searchStatus} /></div>++ <button className="btn btn-sm" onClick={() => sendMessage({ name: "trigger-trilium-search" })}>check</button>-- <div>Status: <ConnectionStatus status={searchStatus} /></div></div></div>);@@ -145,7 +148,7 @@ function LinkWithNoteForm({ onCancel }: { onCancel: () => void }) {/><div>- <label>+ <label className="tn-checkbox"><inputtype="checkbox"checked={keepTitle}@@ -155,10 +158,10 @@ function LinkWithNoteForm({ onCancel }: { onCancel: () => void }) {</label></div><div className="save-link-with-note-buttons">- <button type="submit" className="button wide save-button" onClick={save}>Save</button>+ <button type="submit" className="btn btn-primary" onClick={save}>Save</button><buttontype="submit"- className="button wide"+ className="btn btn-secondary"onClick={() => {onCancel();window.close();diff --git a/apps/web-clipper/entrypoints/popup/popup.css b/apps/web-clipper/entrypoints/popup/popup.cssindex 0466910bcf..4650332c57 100644--- a/apps/web-clipper/entrypoints/popup/popup.css+++ b/apps/web-clipper/entrypoints/popup/popup.css@@ -1,80 +1,89 @@body {- width: 300px;- font-size: 12px;- font-family: sans-serif;+ width: 320px;}.popup {+ display: flex;+ flex-direction: column;+ gap: 12px;+ padding: 12px;+.popup-header {display: flex;+ align-items: center;justify-content: space-between;+ gap: 8px;++ h3 {+ margin: 0;+ font-size: 1.1em;+ }}.popup-header-buttons {- position: relative;- top: 6px;+ display: flex;+ gap: 4px;}- .button {- margin: 3% auto;- padding: 4px;- text-align: center;- border: 1px solid #ccc;- border-radius: 3px;- background-color: #eee;- cursor: pointer;- color: black;-- &[disabled] {- color: #aaa;- }+ button.btn.btn-sm {+ min-width: unset;+ padding: 2px 10px;}- .wide {- min-width: 8em;+ .already-visited:empty {+ display: none;}- .full {- display: block;- width: 100%;- }+ .capture-buttons {+ display: flex;+ flex-direction: column;+ gap: 6px;- .already-visited a {- color: lightskyblue;+ button.btn {+ width: 100%;+ }}- .save-link-with-note textarea {- width: 100%;+ .save-link-with-note {+ display: flex;+ flex-direction: column;+ gap: 8px;++ textarea {+ width: 100%;+ resize: vertical;+ }}.save-link-with-note-buttons {display: flex;- }+ justify-content: flex-end;+ gap: 6px;- .save-button {- border-color: #0062cc;- background-color: #0069d9;- color: white;+ button.btn {+ min-width: 80px;+ }}.connection {- margin-top: 15px;- }-- .check-connection-button {- float: right;- margin-top: -6px;+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 8px;+ padding-top: 10px;+ border-top: 1px solid var(--main-border-color);+ color: var(--muted-text-color);}.status-ok {- color: green;+ color: var(--status-ok-color);}.status-warning {- color: orange;+ color: var(--status-warning-color);}.status-error {- color: red;+ color: var(--status-error-color);}}diff --git a/apps/web-clipper/entrypoints/popup/popup.spec.tsx b/apps/web-clipper/entrypoints/popup/popup.spec.tsxindex 16e4e404f8..0d8beeec1f 100644--- a/apps/web-clipper/entrypoints/popup/popup.spec.tsx+++ b/apps/web-clipper/entrypoints/popup/popup.spec.tsx@@ -156,7 +156,7 @@ async function click(text: string) {}function captureButtons() {- return [ ...container.querySelectorAll<HTMLButtonElement>("button.full") ];+ return [ ...container.querySelectorAll<HTMLButtonElement>(".capture-buttons button") ];}function statusText() {diff --git a/apps/web-clipper/package.json b/apps/web-clipper/package.jsonindex 8df065cf4b..1c69d40dcf 100644--- a/apps/web-clipper/package.json+++ b/apps/web-clipper/package.json@@ -17,6 +17,7 @@"keywords": [],"packageManager": "[email protected]","devDependencies": {+ "@triliumnext/client": "workspace:*","@wxt-dev/auto-icons": "1.1.2","jszip": "3.10.2","web-ext": "^10.7.0",diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex eb814c8add..ab8aa031cf 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1028,6 +1028,9 @@ importers:specifier: 11.0.0version: 11.0.0([email protected])devDependencies:+ '@triliumnext/client':+ specifier: workspace:*+ version: link:../client'@wxt-dev/auto-icons':specifier: 1.1.2version: 1.1.2(@types/[email protected])([email protected]([email protected])([email protected]([email protected])([email protected]))([email protected])([email protected])([email protected](@types/[email protected])([email protected])([email protected])([email protected])([email protected])([email protected])([email protected]))([email protected]([email protected]([email protected]))([email protected])([email protected]))([email protected]([email protected])([email protected])([email protected])([email protected](@types/[email protected]))))