fix(reader): scope reading theme to viewport, wire up font/size/line-height to shadow DOM
Two root causes fixed: 1. Reading theme CSS variables were on document.body, leaking font/color into chrome UI. Now scoped to #reader-viewport so chrome keeps its own theme (system font, --text-primary colors) while the reading area uses reading theme colors/background. 2. getCSS() never received font family, font size, or line height settings. The settings UI (dropdowns, sliders) saved values but they were never injected into the book's shadow DOM. Now getCSS() accepts all four settings and generates proper CSS rules for them. Changes: - Wrap foliate-view in #reader-viewport div (absolute positioned between chrome bars) - getCSS() reads computed style from #reader-viewport, not document.body - getCSS() params expanded: fontFamily, fontSize, lineHeight, justify, hyphenate (removed unused 'spacing') - Added FONT_MAP to translate setting keys to CSS font-family values - applyTheme() targets #reader-viewport instead of document.body - Removed dead #reader-viewport typography rules from foliate-themes.css (shadow DOM doesn't inherit outer styles), kept only background-color
This commit is contained in:
@@ -6,6 +6,20 @@
|
||||
CATEGORY 1: CLASSIC READING (6 themes)
|
||||
Time-tested, comfortable for long sessions
|
||||
========================================== */
|
||||
#reader-viewport {
|
||||
background-color: var(--reader-bg);
|
||||
color: var(--reader-text);
|
||||
font-family: var(--reader-font, "Literata", serif);
|
||||
font-size: var(--reader-font-size, 16px);
|
||||
line-height: var(--reader-line-height, 1.6);
|
||||
}
|
||||
#reader-viewport ::selection {
|
||||
background-color: var(--reader-selection);
|
||||
}
|
||||
#reader-viewport a {
|
||||
color: var(--reader-link);
|
||||
text-decoration: underline;
|
||||
}
|
||||
/* Light - Default theme */
|
||||
.theme-light {
|
||||
--reader-bg: #fafafa;
|
||||
@@ -256,4 +270,6 @@
|
||||
--reader-link: #268bd2;
|
||||
--reader-selection: #073642;
|
||||
}
|
||||
|
||||
#reader-viewport {
|
||||
background-color: var(--reader-bg);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user