feat: feat: 优化事件卡片 UI 和交互体验

修复 useColorModeValue 调用位置(提升到顶层)
优化分页和滚动逻辑
动态 indicatorSize 支持(detail/list 模式)
This commit is contained in:
zdl
2025-11-05 19:15:36 +08:00
parent 27b68e928e
commit 612b58c983
4 changed files with 66 additions and 68 deletions

View File

@@ -33,6 +33,7 @@ import StockChangeIndicators from '../../../../components/StockChangeIndicators'
* @param {Function} props.onToggleFollow - 切换关注事件
* @param {Object} props.timelineStyle - 时间轴样式配置
* @param {string} props.borderColor - 边框颜色
* @param {string} props.indicatorSize - 涨幅指标尺寸 ('default' | 'comfortable' | 'large')
*/
const HorizontalDynamicNewsEventCard = ({
event,
@@ -45,9 +46,15 @@ const HorizontalDynamicNewsEventCard = ({
onToggleFollow,
timelineStyle,
borderColor,
indicatorSize = 'comfortable',
}) => {
const importance = getImportanceConfig(event.importance);
// 所有 useColorModeValue 必须在顶层调用
const cardBg = useColorModeValue('white', 'gray.800');
const cardBgAlt = useColorModeValue('gray.50', 'gray.750');
const selectedBg = useColorModeValue('blue.50', 'blue.900');
const selectedBorderColor = useColorModeValue('blue.500', 'blue.400');
const linkColor = useColorModeValue('blue.600', 'blue.400');
return (
@@ -65,12 +72,12 @@ const HorizontalDynamicNewsEventCard = ({
flex="1"
position="relative"
bg={isSelected
? useColorModeValue('blue.50', 'blue.900')
: (index % 2 === 0 ? cardBg : useColorModeValue('gray.50', 'gray.750'))
? selectedBg
: (index % 2 === 0 ? cardBg : cardBgAlt)
}
borderWidth={isSelected ? "2px" : "1px"}
borderColor={isSelected
? useColorModeValue('blue.500', 'blue.400')
? selectedBorderColor
: borderColor
}
borderRadius="md"
@@ -137,7 +144,7 @@ const HorizontalDynamicNewsEventCard = ({
avgChange={event.related_avg_chg}
maxChange={event.related_max_chg}
weekChange={event.related_week_chg}
size="comfortable"
size={indicatorSize}
/>
</VStack>
</CardBody>