-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
feat: web clipper dark mode #9378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 3 commits
faadb3e
de39225
0ce4dea
b18c379
2b9a93e
c3d21b2
d784dac
67f5ec1
939a3b0
42a6aa3
12780f5
f3db288
744bbd9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -136,4 +136,23 @@ async function restoreOptions() { | |
| $triliumDesktopPort.val(triliumDesktopPort); | ||
| } | ||
|
|
||
| $(restoreOptions); | ||
| const $darkModeButton = $("#dark-mode-button"); | ||
|
|
||
| function loadDarkModePreference() { | ||
| const isDarkMode = localStorage.getItem('darkMode') === 'true'; | ||
| if (isDarkMode) { | ||
| document.body.classList.add('dark-mode'); | ||
| $darkModeButton.text('Light mode'); | ||
| } | ||
| } | ||
|
|
||
| $darkModeButton.on("click", () => { | ||
| const isDarkMode = document.body.classList.toggle('dark-mode'); | ||
| localStorage.setItem('darkMode', isDarkMode.toString()); | ||
| $darkModeButton.text(isDarkMode ? 'Light mode' : 'Dark mode'); | ||
| }); | ||
|
Lorinc936 marked this conversation as resolved.
Outdated
Comment on lines
+141
to
+156
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Comment on lines
+141
to
+156
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic for managing dark mode (loading the preference and handling the toggle) is identical to the implementation in |
||
|
|
||
| $(async () => { | ||
| loadDarkModePreference(); | ||
| await restoreOptions(); | ||
| }); | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| :root { | ||
| --bg-color: #ffffff; | ||
| --text-color: #000000; | ||
| --input-bg: #ffffff; | ||
| --input-text: #000000; | ||
| --input-border: #cccccc; | ||
| --link-color: #0066cc; | ||
| --button-bg: #f0f0f0; | ||
| --button-text: #000000; | ||
| --table-border: #cccccc; | ||
| } | ||
|
|
||
| body.dark-mode { | ||
| --bg-color: #1e1e1e; | ||
| --text-color: #e0e0e0; | ||
| --input-bg: #2d2d2d; | ||
| --input-text: #e0e0e0; | ||
| --input-border: #555555; | ||
| --link-color: #66b3ff; | ||
| --button-bg: #333333; | ||
| --button-text: #e0e0e0; | ||
| --table-border: #555555; | ||
| } | ||
|
|
||
| body { | ||
|
Lorinc936 marked this conversation as resolved.
|
||
| font-family: sans-serif; | ||
| background-color: var(--bg-color); | ||
| color: var(--text-color); | ||
| padding: 20px; | ||
| transition: background-color 0.3s, color 0.3s; | ||
| } | ||
|
|
||
| h1, h2 { | ||
| color: var(--text-color); | ||
| } | ||
|
|
||
| p { | ||
| color: var(--text-color); | ||
| } | ||
|
|
||
| input[type="text"], | ||
| input[type="password"] { | ||
| background-color: var(--input-bg); | ||
| color: var(--input-text); | ||
| border: 1px solid var(--input-border); | ||
| padding: 4px; | ||
| border-radius: 3px; | ||
| font-family: sans-serif; | ||
| } | ||
|
|
||
| input[type="submit"] { | ||
| background-color: var(--button-bg); | ||
| color: var(--button-text); | ||
| border: 1px solid var(--input-border); | ||
| padding: 4px 8px; | ||
| border-radius: 3px; | ||
| cursor: pointer; | ||
| font-family: sans-serif; | ||
| } | ||
|
|
||
| input[type="submit"]:hover { | ||
| opacity: 0.8; | ||
| } | ||
|
|
||
| a { | ||
| color: var(--link-color); | ||
| } | ||
|
|
||
| table { | ||
| border-collapse: collapse; | ||
| } | ||
|
|
||
| table tr th, | ||
| table tr td { | ||
| text-align: left; | ||
| padding: 8px; | ||
| color: var(--text-color); | ||
| border-bottom: 1px solid var(--table-border); | ||
| } | ||
|
|
||
| table tr th { | ||
| font-weight: bold; | ||
| } | ||
|
|
||
| .dark-mode-btn { | ||
| background-color: var(--button-bg); | ||
| color: var(--button-text); | ||
| border: 1px solid var(--input-border); | ||
| padding: 4px 8px; | ||
| border-radius: 3px; | ||
| cursor: pointer; | ||
| font-family: sans-serif; | ||
| white-space: nowrap; | ||
| } | ||
|
Lorinc936 marked this conversation as resolved.
Outdated
|
||
|
|
||
| .dark-mode-btn:hover { | ||
| opacity: 0.8; | ||
| } | ||
|
|
||
| #error-message, | ||
| #success-message { | ||
| padding: 10px; | ||
| border-radius: 3px; | ||
| margin-bottom: 10px; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,18 +1,38 @@ | ||
| :root { | ||
| --bg-color: #ffffff; | ||
| --text-color: #000000; | ||
| --button-bg: #eee; | ||
| --button-border: #ccc; | ||
| --textarea-bg: #ffffff; | ||
| --textarea-text: #000000; | ||
| } | ||
|
|
||
| body.dark-mode { | ||
| --bg-color: #1e1e1e; | ||
| --text-color: #e0e0e0; | ||
| --button-bg: #333333; | ||
| --button-border: #555555; | ||
| --textarea-bg: #2d2d2d; | ||
| --textarea-text: #e0e0e0; | ||
| } | ||
|
Comment on lines
+1
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| body { | ||
| width: 300px; | ||
| width: 335px; | ||
| font-size: 12px; | ||
| font-family: sans-serif; | ||
| background-color: var(--bg-color); | ||
| color: var(--text-color); | ||
| } | ||
|
Lorinc936 marked this conversation as resolved.
|
||
|
|
||
| .button { | ||
| margin: 3% auto; | ||
| padding: 4px; | ||
| text-align: center; | ||
| border: 1px solid #ccc; | ||
| border: 1px solid var(--button-border); | ||
| border-radius: 3px; | ||
| background-color: #eee; | ||
| background-color: var(--button-bg); | ||
| cursor: pointer; | ||
| color: black; | ||
| color: var(--text-color); | ||
| } | ||
|
|
||
| .wide { | ||
|
|
@@ -30,6 +50,11 @@ body { | |
|
|
||
| #save-link-with-note-textarea { | ||
| width: 100%; | ||
| background-color: var(--textarea-bg); | ||
| color: var(--textarea-text); | ||
| border: 1px solid var(--button-border); | ||
| padding: 4px; | ||
| border-radius: 3px; | ||
| } | ||
|
|
||
| #save-button { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.