feat: 创建原子组件(Atoms) - EventTimeline: 时间轴显示(60行) │ │
│ │ - EventImportanceBadge: 重要性等级标签(100行) │ │ │ │ - EventStats: 统计信息组件(60行) │ │ │ │ - EventFollowButton: 关注按钮(40行) │ │ │ │ - EventPriceDisplay: 价格变动显示(130行) │ │ │ │ - EventDescription: 描述文本组件(60行)
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
// src/views/Community/components/EventCard/EventFollowButton.js
|
||||
import React from 'react';
|
||||
import { Button } from '@chakra-ui/react';
|
||||
import { StarIcon } from '@chakra-ui/icons';
|
||||
|
||||
/**
|
||||
* 事件关注按钮组件
|
||||
* @param {Object} props
|
||||
* @param {boolean} props.isFollowing - 是否已关注
|
||||
* @param {number} props.followerCount - 关注数
|
||||
* @param {Function} props.onToggle - 切换关注状态的回调函数
|
||||
* @param {string} props.size - 按钮尺寸('xs' | 'sm' | 'md',默认 'sm')
|
||||
* @param {boolean} props.showCount - 是否显示关注数(默认 true)
|
||||
*/
|
||||
const EventFollowButton = ({
|
||||
isFollowing,
|
||||
followerCount = 0,
|
||||
onToggle,
|
||||
size = 'sm',
|
||||
showCount = true
|
||||
}) => {
|
||||
const iconSize = size === 'xs' ? '10px' : '12px';
|
||||
|
||||
const handleClick = (e) => {
|
||||
e.stopPropagation();
|
||||
onToggle?.();
|
||||
};
|
||||
|
||||
return (
|
||||
<Button
|
||||
size={size}
|
||||
colorScheme="yellow"
|
||||
variant={isFollowing ? 'solid' : 'outline'}
|
||||
leftIcon={<StarIcon boxSize={iconSize} />}
|
||||
onClick={handleClick}
|
||||
>
|
||||
{isFollowing ? '已关注' : '关注'}
|
||||
{showCount && followerCount > 0 && `(${followerCount})`}
|
||||
</Button>
|
||||
);
|
||||
};
|
||||
|
||||
export default EventFollowButton;
|
||||
Reference in New Issue
Block a user