mirror of
https://github.com/dergigi/boris.git
synced 2026-01-19 06:44:23 +01:00
feat: show reading progress in Explore and Bookmarks sidebar
- Add reading position loading to Explore component - Add reading position loading to useBookmarksData hook - Display progress bars in Explore tab blog posts - Display progress bars in Bookmarks large preview view - Progress shown as colored bar (green for completed, orange for in-progress) - Only shown for kind:30023 articles with saved reading positions - Requires syncReadingPosition setting to be enabled
This commit is contained in:
@@ -23,6 +23,7 @@ interface LargeViewProps {
|
||||
handleReadNow: (e: React.MouseEvent<HTMLButtonElement>) => void
|
||||
articleSummary?: string
|
||||
contentTypeIcon: IconDefinition
|
||||
readingProgress?: number // 0-1 reading progress (optional)
|
||||
}
|
||||
|
||||
export const LargeView: React.FC<LargeViewProps> = ({
|
||||
@@ -38,11 +39,19 @@ export const LargeView: React.FC<LargeViewProps> = ({
|
||||
getAuthorDisplayName,
|
||||
handleReadNow,
|
||||
articleSummary,
|
||||
contentTypeIcon
|
||||
contentTypeIcon,
|
||||
readingProgress
|
||||
}) => {
|
||||
const cachedImage = useImageCache(previewImage || undefined)
|
||||
const isArticle = bookmark.kind === 30023
|
||||
|
||||
// Calculate progress display
|
||||
const progressPercent = readingProgress ? Math.round(readingProgress * 100) : 0
|
||||
const progressColor =
|
||||
progressPercent >= 95 ? '#10b981' : // green for completed
|
||||
progressPercent > 5 ? '#f97316' : // orange for in-progress
|
||||
'var(--color-border)' // default for not started
|
||||
|
||||
const triggerOpen = () => handleReadNow({ preventDefault: () => {} } as React.MouseEvent<HTMLButtonElement>)
|
||||
const handleKeyDown: React.KeyboardEventHandler<HTMLDivElement> = (e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
@@ -92,6 +101,28 @@ export const LargeView: React.FC<LargeViewProps> = ({
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Reading progress indicator for articles - shown only if there's progress */}
|
||||
{isArticle && readingProgress !== undefined && readingProgress > 0 && (
|
||||
<div
|
||||
style={{
|
||||
height: '3px',
|
||||
width: '100%',
|
||||
background: 'var(--color-border)',
|
||||
overflow: 'hidden',
|
||||
marginTop: '0.75rem'
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
height: '100%',
|
||||
width: `${progressPercent}%`,
|
||||
background: progressColor,
|
||||
transition: 'width 0.3s ease, background 0.3s ease'
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="large-footer">
|
||||
<span className="bookmark-type-large">
|
||||
<FontAwesomeIcon icon={contentTypeIcon} className="content-type-icon" />
|
||||
|
||||
Reference in New Issue
Block a user