Add epubjs theme support to the book player

Add a dark theme to the book player via epubjs. The theme itself uses
the dark theme of Jellyfin and only changes the colour of the text.

For everything but the text, the dark theme from Jellyfin is retained.
Should any other theme than the dark theme be chosen by the user, epubjs
falls back to it's default theme.
This commit is contained in:
Patrick Farwick 2022-09-23 15:35:54 +00:00
parent 98d6c823e8
commit cb9e7ba432

View file

@ -9,6 +9,7 @@ import Screenfull from 'screenfull';
import TableOfContents from './tableOfContents'; import TableOfContents from './tableOfContents';
import dom from '../../scripts/dom'; import dom from '../../scripts/dom';
import { translateHtml } from '../../scripts/globalize'; import { translateHtml } from '../../scripts/globalize';
import * as userSettings from '../../scripts/settings/userSettings';
import '../../elements/emby-button/paper-icon-button-light'; import '../../elements/emby-button/paper-icon-button-light';
@ -294,6 +295,12 @@ export class BookPlayer {
this.currentSrc = downloadHref; this.currentSrc = downloadHref;
this.rendition = rendition; this.rendition = rendition;
rendition.themes.register('dark', { 'body': { 'color': '#fff' } });
if (userSettings.theme(undefined) === 'dark' || userSettings.theme(undefined) === null) {
rendition.themes.select('dark');
}
return rendition.display().then(() => { return rendition.display().then(() => {
const epubElem = document.querySelector('.epub-container'); const epubElem = document.querySelector('.epub-container');
epubElem.style.opacity = '0'; epubElem.style.opacity = '0';