Skip to content

Commit

Permalink
Media Overlay: fix highlighting when using themes
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfactotum committed Oct 7, 2023
1 parent ab0c905 commit 1628022
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/foliate-js
Submodule foliate-js updated 2 files
+16 −5 epub.js
+2 −1 view.js
14 changes: 13 additions & 1 deletion src/reader/reader.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@ const open = async file => {
emit({ type: 'book-ready', book, reader })
}

const getCSS = ({ lineHeight, justify, hyphenate, invert, theme, userStylesheet }) => [`
const getCSS = ({
lineHeight, justify, hyphenate, invert, theme, userStylesheet,
mediaActiveClass,
}) => [`
@namespace epub "http://www.idpf.org/2007/ops";
@media print {
html {
Expand Down Expand Up @@ -209,6 +212,10 @@ const getCSS = ({ lineHeight, justify, hyphenate, invert, theme, userStylesheet
svg, img {
background-color: transparent !important;
mix-blend-mode: multiply;
}
.${CSS.escape(mediaActiveClass)}, .${CSS.escape(mediaActiveClass)} * {
color: ${theme.light.fg} !important;
background: color-mix(in lch, ${theme.light.fg}, ${theme.light.bg} 85%) !important;
}` : ''}
}
@media (prefers-color-scheme: dark) {
Expand All @@ -224,6 +231,10 @@ const getCSS = ({ lineHeight, justify, hyphenate, invert, theme, userStylesheet
}
a:any-link {
color: ${theme.dark.link} !important;
}
.${CSS.escape(mediaActiveClass)}, .${CSS.escape(mediaActiveClass)} * {
color: ${theme.dark.fg} !important;
background: color-mix(in lch, ${theme.dark.fg}, ${theme.dark.bg} 75%) !important;
}`}
}
p, li, blockquote, dd {
Expand Down Expand Up @@ -307,6 +318,7 @@ class Reader {
book.metadata.description = toPangoMarkup(book.metadata.description)
this.pageTotal = book.pageList
?.findLast(x => !isNaN(parseInt(x.label)))?.label
this.style.mediaActiveClass = book.media?.activeClass
}
async init() {
this.view = document.createElement('foliate-view')
Expand Down

0 comments on commit 1628022

Please sign in to comment.