diff --git a/src/components/ContentPanel.tsx b/src/components/ContentPanel.tsx index e38e0f73..01bd636e 100644 --- a/src/components/ContentPanel.tsx +++ b/src/components/ContentPanel.tsx @@ -2,12 +2,13 @@ import React, { useMemo, useEffect, useRef, useState } from 'react' import ReactMarkdown from 'react-markdown' import remarkGfm from 'remark-gfm' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { faSpinner, faHighlighter, faClock } from '@fortawesome/free-solid-svg-icons' +import { faSpinner } from '@fortawesome/free-solid-svg-icons' import { Highlight } from '../types/highlights' import { applyHighlightsToHTML } from '../utils/highlightMatching' import { readingTime } from 'reading-time-estimator' import { filterHighlightsByUrl } from '../utils/urlHelpers' import { hexToRgb } from '../utils/colorHelpers' +import ReaderHeader from './ReaderHeader' interface ContentPanelProps { loading: boolean @@ -162,30 +163,13 @@ const ContentPanel: React.FC = ({ )} - {image && ( -
- {title -
- )} - {title && ( -
-

{title}

-
- {readingStats && ( -
- - {readingStats.text} -
- )} - {hasHighlights && ( -
- - {relevantHighlights.length} highlight{relevantHighlights.length !== 1 ? 's' : ''} -
- )} -
-
- )} + {markdown || html ? ( markdown ? ( finalHtml ? ( diff --git a/src/components/ReaderHeader.tsx b/src/components/ReaderHeader.tsx new file mode 100644 index 00000000..bca51fb8 --- /dev/null +++ b/src/components/ReaderHeader.tsx @@ -0,0 +1,52 @@ +import React from 'react' +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' +import { faHighlighter, faClock } from '@fortawesome/free-solid-svg-icons' + +interface ReaderHeaderProps { + title?: string + image?: string + readingTimeText?: string | null + hasHighlights: boolean + highlightCount: number +} + +const ReaderHeader: React.FC = ({ + title, + image, + readingTimeText, + hasHighlights, + highlightCount +}) => { + return ( + <> + {image && ( +
+ {title +
+ )} + {title && ( +
+

{title}

+
+ {readingTimeText && ( +
+ + {readingTimeText} +
+ )} + {hasHighlights && ( +
+ + {highlightCount} highlight{highlightCount !== 1 ? 's' : ''} +
+ )} +
+
+ )} + + ) +} + +export default ReaderHeader + +