From af8f036ca35becbbd237b224e3039d93331facaa Mon Sep 17 00:00:00 2001 From: Huang Xin Date: Fri, 13 Feb 2026 00:43:11 +0800 Subject: [PATCH] fix(annotator): apply custom highlight colors in sidebar, closes #3273 (#3278) --- .../components/sidebar/BooknoteItem.tsx | 25 +++++++++++++++---- .../components/sidebar/ContentNavBar.tsx | 2 +- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/apps/readest-app/src/app/reader/components/sidebar/BooknoteItem.tsx b/apps/readest-app/src/app/reader/components/sidebar/BooknoteItem.tsx index dd17e775..3b40842c 100644 --- a/apps/readest-app/src/app/reader/components/sidebar/BooknoteItem.tsx +++ b/apps/readest-app/src/app/reader/components/sidebar/BooknoteItem.tsx @@ -4,7 +4,7 @@ import React, { useRef, useState } from 'react'; import { marked } from 'marked'; import { useEnv } from '@/context/EnvContext'; -import { BookNote } from '@/types/book'; +import { BookNote, HighlightColor } from '@/types/book'; import { useSettingsStore } from '@/store/settingsStore'; import { useReaderStore } from '@/store/readerStore'; import { useNotebookStore } from '@/store/notebookStore'; @@ -31,6 +31,9 @@ const BooknoteItem: React.FC = ({ bookKey, item, onClick }) = const { getProgress, getView, getViewsById } = useReaderStore(); const { setNotebookEditAnnotation, setNotebookVisible } = useNotebookStore(); + const globalReadSettings = settings.globalReadSettings; + const customColors = globalReadSettings.customHighlightColors; + const { text, cfi, note } = item; const editorRef = useRef(null); const [editorDraft, setEditorDraft] = useState(text || ''); @@ -181,11 +184,23 @@ const BooknoteItem: React.FC = ({ bookKey, item, onClick }) = item.note && 'content font-size-xs text-gray-500', (item.style === 'underline' || item.style === 'squiggly') && 'underline decoration-2', - item.style === 'highlight' && - `bg-${item.color}-500 rounded-[4px] bg-opacity-40 px-[2px] py-[1px]`, - item.style === 'underline' && `decoration-${item.color}-400`, - item.style === 'squiggly' && `decoration-wavy decoration-${item.color}-400`, + item.style === 'highlight' && 'rounded-[4px] px-[2px] py-[1px]', + item.style === 'squiggly' && 'decoration-wavy', )} + style={ + { + ...(item.style === 'highlight' + ? { + backgroundColor: `color-mix(in srgb, ${customColors[item.color as HighlightColor] || item.color} calc(var(--overlayer-highlight-opacity, 0.3) * 100%), transparent)`, + } + : {}), + ...(item.style === 'underline' || item.style === 'squiggly' + ? { + textDecorationColor: `color-mix(in srgb, ${customColors[item.color as HighlightColor] || item.color} 80%, transparent)`, + } + : {}), + } as React.CSSProperties + } > {text || ''} diff --git a/apps/readest-app/src/app/reader/components/sidebar/ContentNavBar.tsx b/apps/readest-app/src/app/reader/components/sidebar/ContentNavBar.tsx index 3d178eda..a512f9a2 100644 --- a/apps/readest-app/src/app/reader/components/sidebar/ContentNavBar.tsx +++ b/apps/readest-app/src/app/reader/components/sidebar/ContentNavBar.tsx @@ -67,7 +67,7 @@ const ContentNavBar: React.FC = ({ left: gridInsets.left, }} > -
+
{/* Bottom bar: Navigation buttons and Info */}
{/* Previous button */}