Skip to content

Commit

Permalink
Added basic dark mode compatibility for Zotero 7
Browse files Browse the repository at this point in the history
  • Loading branch information
frianasoa committed Sep 30, 2024
1 parent 2981572 commit 7acd9ef
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 15 deletions.
66 changes: 66 additions & 0 deletions content/notes/notes-dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
html {
color: white;
background: black;
}

a {
color: white;
}

#notes-table tr:first-child td {
background-color: black!important;
}

.rm-item-exists td
{
background-color: rgb(25, 25, 55);
}

.rm-id {
color: white;
}

#notes-table td:first-child {
background-color: black;
}

#zn-sep-1 {
background-color: black;
height: 1.3em;
}

.zn-menubar {
background-color: black!important;
}

.zn-menubar li {
background-color: black;
border: solid 1px black;
color: white;
}

.context-menu-separator
{
border: solid 1px black;
}

.zn-status-bar {
background-color: black;
color: white;
}

.context-menu-two {
background-color: black;
border: solid 1px black;
}

.zn-menuitem {
border: solid 1px black;
background-color: black;
color: white;
}

.zn-menuitem:hover {
background-color: black;
border-bottom: solid 1px white;
}
2 changes: 1 addition & 1 deletion content/notes/notes.css
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ body {

.context-menu-separator
{
border: solid 1px #dfdfff!important;
border: solid 1px #dfdfff;
}

.zn-menuitem:hover {
Expand Down
22 changes: 19 additions & 3 deletions content/notes/notes.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,15 +365,30 @@ Notes = {
Notes.body.style.fontSize = this.fontsize+"em";
let pxsize = parseFloat(getComputedStyle(Notes.body).fontSize);
Zotero.ZeNotes.Prefs.set("font-size", pxsize);
}
},

loaddark()
{
var isdark = Zotero.Prefs.get('general.theme')=="dark" || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

if(isdark)
{
var filename = "chrome://ze-notes/content/notes/notes-dark.css";
const link = document.createElement("link");
link.rel = "stylesheet";
link.type = "text/css";
link.href = filename;
document.head.appendChild(link);
}
}
}

window.addEventListener("load", function(){
Notes.init();
Notes.loaddata();
Notes.initscroll();
})
Notes.loaddark();
});

document.addEventListener("wheel", function(e){
if(e.ctrlKey){
Expand Down Expand Up @@ -401,4 +416,5 @@ document.addEventListener("keyup", function(e){
Notes.zoom(sign);
}
}
})
});

2 changes: 0 additions & 2 deletions content/notes/zotero.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,3 @@ else
{
var Zotero = window.parent.Zotero;
}

// Zotero.Utilities.Internal.openPreferences('zotero-prefpane-advanced');
2 changes: 2 additions & 0 deletions content/settings/generative-ai.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<td>Model</td>
<td> <select id="zn-openai-model" onchange="Zotero_Preferences.ZeNotes.setpreference(event, 'openai-model');" oncommand="Zotero_Preferences.ZeNotes.setpreference(event, 'openai-model');" style="width:100%;" placeholder="Model">
<option value="">Choose model</option>
<option value="gpt-4o">GPT 4o</option>
<option value="gpt-4o-mini">GPT 4o Mini</option>
<option value="gpt-3.5-turbo">GPT 3.5 Turbo</option>
<option value="gpt-4">GPT 4</option>
</select></td>
Expand Down
17 changes: 17 additions & 0 deletions content/settings/preferences-dark.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
html, body {
color: white;
background-color: #303030;
}

.zn-type-table {
background-color: #303030;
}

.zn-type-table thead{
color: white;
background-color: #303030;
}

.zn-type-table tr:hover{
background-color: #333d54;
}
19 changes: 19 additions & 0 deletions content/settings/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ Zotero_Preferences.ZeNotes = {

loadtagmanager(box)
{
Zotero_Preferences.ZeNotes.loaddark();
var table = box.querySelector("#table-manage-tags-body");
var buttonlist = ["up", "down", "first", "last", "visible"];
box.parentNode.querySelector(".collection-name").innerHTML = this.collection;
Expand Down Expand Up @@ -521,9 +522,27 @@ Zotero_Preferences.ZeNotes = {
}
})
return s;
},
loaddark()
{
var isdark = Zotero.Prefs.get('general.theme')=="dark" || window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;

if (isdark) {
var filename = "chrome://ze-notes/content/settings/preferences-dark.css";
var pi = document.createProcessingInstruction(
'xml-stylesheet',
`type="text/css" href="${filename}"`
);
document.insertBefore(pi, document.documentElement);
}
}
}


this.addEventListener("load", function(){
// Zotero_Preferences.ZeNotes.loaddark();
});

/**
Refresh after losing focus
*/
Expand Down
2 changes: 1 addition & 1 deletion content/settings/zntable.js
Original file line number Diff line number Diff line change
Expand Up @@ -454,4 +454,4 @@ Zotero_Preferences.ZNTable = {
}
return html;
}
}
}
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Description about="urn:mozilla:install-manifest">
<em:id>[email protected]</em:id>
<em:name>ZeNotes</em:name>
<em:version>0.8.4</em:version>
<em:version>0.8.5</em:version>
<em:multiprocessCompatible>true</em:multiprocessCompatible>
<em:updateURL>https://raw.githubusercontent.com/frianasoa/zenotes/main/zenote-update.json</em:updateURL>
<em:homepageURL>https://github.com/frianasoa/zenotes</em:homepageURL>
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Ze Notes",
"version": "0.8.4",
"version": "0.8.5",
"description": "Advanced notes manager",
"homepage_url": "https://github.com/frianasoa/zenotes",
"author": "Fanantenana Rianasoa Andriariniaina",
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"[email protected]": {
"updates": [
{
"version": "0.8.4",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.4/zenotes-v0.8.4.xpi",
"update_hash": "sha256:3808e0cde9efaddab594802acc24b01e918d12137c7469cff734734459faf8fc",
"version": "0.8.5",
"update_link": "https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.5/zenotes-v0.8.5.xpi",
"update_hash": "sha256:b4ddddfba03f1cdea9660ebe785a3824d164657aaa0bbe01376c892b14325f9b",
"applications": {
"gecko": {
"strict_min_version": "60.0"
Expand Down
6 changes: 3 additions & 3 deletions zenote-update.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<rdf:Seq>
<rdf:li>
<rdf:Description>
<ns1:version>0.8.4</ns1:version>
<ns1:version>0.8.5</ns1:version>
<ns1:targetApplication>
<rdf:Description>
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>5.0.0</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.4/zenotes-v0.8.4.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.5/zenotes-v0.8.5.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand All @@ -20,7 +20,7 @@
<ns1:id>[email protected]</ns1:id>
<ns1:minVersion>4.999</ns1:minVersion>
<ns1:maxVersion>6.*</ns1:maxVersion>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.4/zenotes-v0.8.4.xpi</ns1:updateLink>
<ns1:updateLink>https://github.com/frianasoa/Ze-Notes/releases/download/v0.8.5/zenotes-v0.8.5.xpi</ns1:updateLink>
</rdf:Description>
</ns1:targetApplication>

Expand Down

0 comments on commit 7acd9ef

Please sign in to comment.