ds300 / jetzt

Speed reader extension for chrome
Other
486 stars 123 forks source link

jetzt Dark Theme #32

Closed ianzapolsky closed 10 years ago

ianzapolsky commented 10 years ago

Implemented a dark theme for the jetzt speedreader

Changes:
 - added a new case to handleKeydown to listen for a button press on `0`. This
   is arbitrary and subject to change.
 - added a control method toggleTheme, which does nothing other than call
   the new toggleTheme method in Reader (see next bullet).
 - added a method toggleTheme in Reader, which uses two added CSS classes,
   dark-theme and sr-pivot-dark, to change the appearance of the jetzt reader
   from black/red on white/gray to white/green on black/gray.
 - exposed wordBox as its own element in Reader, to allow for the easier
   maniuplation of its CSS classes.
 - added a variable called theme to reader, which keeps track of the current
   theme of the reader (true = light, false = dark)
 - added various comments in places where I made changes.

I saw this on the todo list and thought it was low hanging fruit that I could
tackle. This is my first contribution to an open source project. Please be
kind, and if I did royally screw something up, I would love to hear about how
I can avoid that in the future in a constructive way.

ianzapolsky
ds300 commented 10 years ago

A good attempt! Alas, there are some issues with the way you've done things:

.sr-reader .sr-word-box {
  flex: 0 0 auto;
  width: 400px;
  background: white;
  position: relative;
}

.sr-reader.sr-dark .sr-word-box {
  background-color: black;
}
function toggleTheme () {
  config("dark", !config("dark"));
  reader && reader.applyTheme();
}

where applyTheme does something like:

if (config("dark")) addClass(box, "sr-dark");
else removeClass(box. "sr-dark");

and should be called at Reader construction time.

I hope none of this sounds too critical, and greatly appreciate your will to contribute :)

ianzapolsky commented 10 years ago

thanks for the detailed notes! I'll rework things and see if I can't hit it better the second time.