feat: add highlight background color support to verse renderer

Enhanced VerseRenderer with highlight background color visualization:
- Added COLOR_MAP constant with rgba colors for yellow, orange, pink, blue
- Imported HighlightColor type from @/types
- Added hoveredVerseNum state for tracking verse hover state
- Updated verse rendering span with:
  - Dynamic backgroundColor based on verse.highlight.color
  - Padding and borderRadius for visual polish
  - Smooth transitions for better UX
  - Proper hover state management

This prepares the UI for highlight data integration in Task 6.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-12 07:02:43 +00:00
parent 8185009da6
commit ec62440b2d

View File

@@ -2,9 +2,16 @@
import { useState, useEffect, CSSProperties } from 'react'
import { Box, Typography, IconButton, Paper, useMediaQuery, useTheme } from '@mui/material'
import { NavigateBefore, NavigateNext, Settings as SettingsIcon } from '@mui/icons-material'
import { BibleChapter } from '@/types'
import { BibleChapter, HighlightColor } from '@/types'
import { getCSSVariables, loadPreferences } from '@/lib/reading-preferences'
const COLOR_MAP: Record<HighlightColor, string> = {
yellow: 'rgba(255, 193, 7, 0.3)',
orange: 'rgba(255, 152, 0, 0.3)',
pink: 'rgba(233, 30, 99, 0.3)',
blue: 'rgba(33, 150, 243, 0.3)'
}
interface ReadingViewProps {
chapter: BibleChapter
loading: boolean
@@ -30,6 +37,7 @@ export function ReadingView({
const isMobile = useMediaQuery(theme.breakpoints.down('sm'))
const [preferences, setPreferences] = useState(loadPreferences())
const [showControls, setShowControls] = useState(!isMobile)
const [hoveredVerseNum, setHoveredVerseNum] = useState<number | null>(null)
useEffect(() => {
const handleStorageChange = () => {
@@ -126,15 +134,14 @@ export function ReadingView({
onVerseClick(verse.id)
}
}}
onMouseEnter={() => setHoveredVerseNum(verse.verseNum)}
onMouseLeave={() => setHoveredVerseNum(null)}
style={{
backgroundColor: (verse as any).highlight ? COLOR_MAP[(verse as any).highlight.color] : 'transparent',
padding: '0.25rem 0.5rem',
borderRadius: '4px',
cursor: 'pointer',
transition: 'background-color 0.15s',
}}
onMouseEnter={(e) => {
e.currentTarget.style.backgroundColor = 'rgba(255, 193, 7, 0.3)'
}}
onMouseLeave={(e) => {
e.currentTarget.style.backgroundColor = 'transparent'
transition: 'all 0.2s ease'
}}
>
<sup style={{ fontSize: '0.8em', marginRight: '0.25em', fontWeight: 600, opacity: 0.6 }}>