mirror of
https://github.com/readest/readest.git
synced 2026-11-29 19:02:28 +00:00
#3761 skipped the whole Override Book Color block rule when a background texture is set, so the override also stopped forcing text and border colors and book text could stay unreadable. With a texture, the override now still forces text and border colors and fills block and span backgrounds with transparent instead of the theme background, so the texture shows through. Without the override or without a texture the generated styles are unchanged. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7e75d60f4b
commit
a09e069133
2 changed files with 18 additions and 4 deletions
|
|
@ -832,6 +832,17 @@ describe('getColorStyles branches (via getStyles)', () => {
|
|||
);
|
||||
});
|
||||
|
||||
it('keeps overriding text colors over a background texture, with transparent fills (#6712)', () => {
|
||||
const vs = makeViewSettings({ overrideColor: true, backgroundTextureId: 'leaves' });
|
||||
const theme = makeThemeCode({ isDarkMode: true, bg: '#1a1a1a', fg: '#e0e0e0' });
|
||||
const css = getStyles(vs, theme);
|
||||
const block = css.match(/section, aside, blockquote[^{]*\{([^}]*)\}/)![1]!;
|
||||
expect(block).toContain('background-color: transparent !important');
|
||||
expect(block).toContain('color: #e0e0e0 !important');
|
||||
expect(block).toContain('border-color: #e0e0e0 !important');
|
||||
expect(css).toMatch(/pre, span \{[^}]*background-color: transparent !important/);
|
||||
});
|
||||
|
||||
it('makes svg/img backgrounds transparent when overrideColor is true', () => {
|
||||
const vs = makeViewSettings({ overrideColor: true });
|
||||
const theme = makeThemeCode();
|
||||
|
|
|
|||
|
|
@ -335,6 +335,9 @@ const getColorStyles = (
|
|||
) => {
|
||||
const { bg, fg, primary, isDarkMode } = themeCode;
|
||||
const hasBackgroundTexture = !!backgroundTextureId && backgroundTextureId !== 'none';
|
||||
// Over a background texture, Override Book Color still forces the text
|
||||
// colors but fills backgrounds with transparent so the texture shows (#6712).
|
||||
const overrideBg = hasBackgroundTexture ? 'transparent' : bg;
|
||||
const colorStyles = `
|
||||
html {
|
||||
--bg-texture-id: ${backgroundTextureId};
|
||||
|
|
@ -360,12 +363,12 @@ const getColorStyles = (
|
|||
}
|
||||
section, aside, blockquote, article, nav, header, footer, main, figure,
|
||||
div, p, font, h1, h2, h3, h4, h5, h6, li, span {
|
||||
${overrideColor && !hasBackgroundTexture ? `background-color: ${bg} !important;` : ''}
|
||||
${overrideColor && !hasBackgroundTexture ? `color: ${fg} !important;` : ''}
|
||||
${overrideColor && !hasBackgroundTexture ? `border-color: ${fg} !important;` : ''}
|
||||
${overrideColor ? `background-color: ${overrideBg} !important;` : ''}
|
||||
${overrideColor ? `color: ${fg} !important;` : ''}
|
||||
${overrideColor ? `border-color: ${fg} !important;` : ''}
|
||||
}
|
||||
pre, span { /* inline code blocks */
|
||||
${overrideColor ? `background-color: ${bg} !important;` : ''}
|
||||
${overrideColor ? `background-color: ${overrideBg} !important;` : ''}
|
||||
}
|
||||
a:any-link {
|
||||
${overrideColor ? `color: ${primary} !important;` : isDarkMode ? `color: lightblue;` : ''}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue