I am making an epub reader with epub.js, and I intend to give a choice to toggle between various styles.
Lets say I want to read the book in dark mode and at a smaller size, so I would first select Dark Mode CSS and then I would select a desired Font Size, but the problem I am facing is that it always picks up the latest style and removes off the previous style. In the above case it scrapes off Dark Mode and just changes the font.
Expected : Dark Mode with smaller font
Actual : Small Font with dark mode removed.
Not only this but I would like to preserve all the previous styles that the user gave and the user should be able to choose a combination of styles.
My JS code that applies style looks like this:
document.getElementById("darkTheme").addEventListener("click", function(){
rendition.themes.register("dark", "themes.css");
rendition.themes.select("dark");
});
Here dark
is a class that contains dark background and rendition.themes.select
selects the class and applies the style present in that class and similarly I have created other classes for various different styles.