kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Add learner-defined custom themes to the EPUB reader

Open rtibbles opened this issue 5 months ago • 3 comments

Summary

Brings the EPUB reader's custom themes feature — originally a GSoC contribution — to merge-readiness on the current codebase. Alongside the six fixed themes, learners can create, edit, and delete their own themes (background, text, and link colors), picked via a color picker and persisted per-device in localStorage.

The feature was functional in the GSoC branch; this branch modernises and hardens it.

State Screenshot
Add / edit theme modal modal
Color picker picker
Custom theme applied (My themes list) applied
Dark fixed theme — accessible link color dark

References

Continues the custom-themes work from the GSoC-era epub-custom-themes branch (merge base ~July 2023). No tracking issue was filed for the original work.

Reviewer guidance

How to test: Open any EPUB and open the reader settings (sliders icon). Under Themes, switch the six fixed themes — check link contrast on the dark ones (Black / Grey / Yellow). Under My themes (signed in), add a theme: name it, pick background/text/link colors, save; confirm it applies, appears in the list, and that rename/edit and delete work.

Deliberate convention departure: the six fixed themes are hardcoded hex in EpubConstants.js rather than $themeTokens/$themePalette, so EPUB reading palettes don't shift with Kolibri's app theme. Intentional, but it diverges from the "use theme tokens" guideline and is worth a deliberate decision.

Two maintenance notes:

  • The alwan accessibility patch in ColorPickerModal.vue keys off the library's internal class/attribute names, so an alwan upgrade could silently turn it into a no-op.
  • The focus-restore calls in SettingsSideBar.vue use $refs.<button>.$el.focus(). KButton gained a public focus() method in KDS 5.8.0, which internally just calls this.$el.focus(); we're pinned to 5.7.0, so we focus $el directly for now. Switch these to the public focus() when KDS is upgraded.

AI usage

Used Claude Code throughout. It reviewed the GSoC-derived branch and, under my direction, modernised and hardened it — converting the components from Options (and mixed) API to Composition API, extracting persistence into the useCustomThemes composable, and adding stable theme ids, accessible link colors, CSS-ellipsis names, an alwan accessibility patch, and the test suite — then drove a headless browser to verify rendering and run axe audits on the new UI. I made the design decisions (theme identity, hardcoded vs token colors, auditing color-picker alternatives before keeping alwan) and critically reviewed and revised its output.

rtibbles avatar Jun 09 '26 03:06 rtibbles

Your delta review is inaccurate. Multiple items are resolved, contrary to your assertions.

rtibbles avatar Jun 22 '26 04:06 rtibbles

You're right — I apologize for the error. The June 22 delta review (02:41 UTC) incorrectly listed 11 items as UNADDRESSED that had already been confirmed RESOLVED in the June 14 full-pipeline review (review 4493785041). The delta's finding-tracking logic went back through multiple prior review rounds and miscalculated resolution status, resurrecting issues that were closed. Withdrawing all 11 UNADDRESSED claims from that review.

rtibblesbot avatar Jun 22 '26 04:06 rtibblesbot

Really nice to see the learner-defined themes! In addition to what's already been mentioned by Marcella I noticed the following issues:

  1. In both Safari (26.5.2) and the Mac app the 'Add new theme' and the 'Delete Theme' modal get partially covered by the epub content when the vertical size of the window gets shrunk:

https://github.com/user-attachments/assets/b79ae55e-4098-4154-ba0e-6d7481804f69

  1. The title of the 'Delete Theme' modal should be changed to 'Delete theme' for consistency
  2. Both the ✔️ of the selected custom theme (and the theme name in some edge cases) become invisible or hard to see if the custom theme is too dark:

https://github.com/user-attachments/assets/897fa640-ee05-48c2-846b-c4d1d35f43ac

  1. The 'previous' and 'next' arrows of the epub reader also remain black when I have applied a custom dark theme which makes them invisible:

https://github.com/user-attachments/assets/23ce11d6-60a8-4093-91fa-0f635601c98f

  1. Improvement suggestion: in the 'Add new theme' modal the button is labeled 'Save' while I would expect it to be called 'Add' or 'Apply theme' because the newly added theme is actually immediately added and applied and not just saved.

pcenov avatar Jul 14 '26 13:07 pcenov

🔵 Review posted

Last updated: 2026-07-16 00:56 UTC

rtibblesbot avatar Jul 15 '26 06:07 rtibblesbot

Thanks @marcellamaki and @pcenov — all points addressed, absorbed into the existing three commits.

Fix Screenshot
Colour-pick flash — picker now swaps inside one modal, so no second overlay fades in.
Active ✔ overflowed the swatch — now centered, with a bold active ring that contrasts the background.
✔ lost on dark themes — ✔ and ring now contrast the swatch, whatever the theme's own colours.
Arrows stayed black on dark themes — colour now from background luminance.
"Save" on an immediate add — add says "Add", edit keeps "Save".
"Delete Theme" — now "Delete theme".
Modals clipped by the book on Safari — translateZ lifts the overlay onto its own layer. Needs a Safari QA pass. —

rtibbles avatar Jul 15 '26 06:07 rtibbles

Thanks, @rtibbles the clipped modals issue remains unresolved in both the Mac app and Safari:

https://github.com/user-attachments/assets/de89c4dd-ef21-40d2-9208-62948212c548

The rest of the issues are fixed.

pcenov avatar Jul 15 '26 09:07 pcenov