Skip to content

Commit 07182c5

Browse files
committed
fix: at rendering time, darken bookmark colours (default yellow bookmark indicator was near invisible in white margin), currently works fine in light and dark color themes...also updated NPM packages (added color manipulation lib)
1 parent 9ff5505 commit 07182c5

File tree

3 files changed

+138
-68
lines changed

3 files changed

+138
-68
lines changed

package-lock.json

Lines changed: 119 additions & 64 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@
281281
"ajv": "^8.17.1",
282282
"ajv-formats": "^3.0.1",
283283
"classnames": "^2.5.1",
284+
"color": "^5.0.0",
284285
"debounce": "^2.2.0",
285286
"debug": "^4.4.0",
286287
"divina-player-js": "git+https://github.com/readium/divina-player-js.git#4e1f859afb14b916923ec136af0284a72e22a990",
@@ -289,7 +290,7 @@
289290
"glob": "^11.0.1",
290291
"history": "^5.3.0",
291292
"i18next": "^24.2.3",
292-
"inversify": "^7.1.0",
293+
"inversify": "^7.2.0",
293294
"jsdom": "^26.0.0",
294295
"lunr": "^2.3.9",
295296
"lunr-languages": "^1.14.0",
@@ -343,7 +344,7 @@
343344
"@axe-core/react": "^4.10.1",
344345
"@babel/generator": "^7.26.10",
345346
"@electron/fuses": "^1.8.0",
346-
"@electron/notarize": "^3.0.0",
347+
"@electron/notarize": "^3.0.1",
347348
"@electron/rebuild": "^3.7.1",
348349
"@jest/globals": "^29.7.0",
349350
"@kogai/typed_i18n": "^0.6.0",

src/renderer/reader/redux/sagas/highlight/mounter.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { eventChannel, SagaIterator } from "redux-saga";
1515
import { put } from "redux-saga/effects";
1616
import { call as callTyped, select as selectTyped } from "typed-redux-saga/macro";
1717

18-
import { IHighlight } from "@r2-navigator-js/electron/common/highlight";
18+
import { HighlightDrawTypeMarginBookmark, IHighlight, IHighlightDefinition } from "@r2-navigator-js/electron/common/highlight";
1919
import {
2020
highlightsCreate, highlightsDrawMargin, highlightsRemove,
2121
} from "@r2-navigator-js/electron/renderer";
@@ -24,6 +24,7 @@ import { readerLocalActionHighlights } from "../../actions";
2424
import {
2525
IHighlightHandlerState, IHighlightMounterState,
2626
} from "readium-desktop/common/redux/states/renderer/highlight";
27+
import Color from "color";
2728

2829
const debug = debug_("readium-desktop:renderer:reader:redux:sagas:highlight:mounter");
2930

@@ -66,7 +67,20 @@ export function* mountHighlight(href: string, handlerState: IHighlightHandlerSta
6667

6768
debug(`mountHighlight CREATE ... -- href: [${href}] highlightDefinitions: [${highlightDefinitions ? highlightDefinitions.length : JSON.stringify(highlightDefinitions, null, 4)}]`);
6869

69-
const createdHighlights = yield* callTyped(highlightsCreate, href, highlightDefinitions);
70+
const createdHighlights = yield* callTyped(highlightsCreate, href, highlightDefinitions.map((def) => {
71+
if (def.drawType === HighlightDrawTypeMarginBookmark) { // TODO: this currently works ok in light/dark color themes, but could be applied more smartly? (user preference?)
72+
const color = Color.rgb(def.color.red, def.color.green, def.color.blue).darken(0.3);
73+
return {
74+
...def,
75+
color: {
76+
red: color.red(),
77+
green: color.green(),
78+
blue: color.blue(),
79+
},
80+
} satisfies IHighlightDefinition;
81+
}
82+
return def;
83+
}));
7084

7185
debug(`mountHighlight CREATED -- href: [${href}] createdHighlights: [${createdHighlights ? createdHighlights.length : JSON.stringify(createdHighlights, null, 4)}]`);
7286

0 commit comments

Comments
 (0)