feat(EventFollowButton): 添加 layout prop 支持垂直布局
- 新增 layout prop: 'horizontal' | 'vertical' - minimal variant 支持上图标下文字的垂直布局 - 垂直模式下调整图标大小和字体 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
// src/views/Community/components/EventCard/atoms/EventFollowButton.js
|
// src/views/Community/components/EventCard/atoms/EventFollowButton.js
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { IconButton, Box, HStack, Text, Tooltip } from '@chakra-ui/react';
|
import { IconButton, Box, HStack, VStack, Text, Tooltip } from '@chakra-ui/react';
|
||||||
import { Star } from 'lucide-react';
|
import { Star } from 'lucide-react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -12,6 +12,7 @@ import { Star } from 'lucide-react';
|
|||||||
* @param {string} props.size - 按钮尺寸('xs' | 'sm' | 'md',默认 'sm')
|
* @param {string} props.size - 按钮尺寸('xs' | 'sm' | 'md',默认 'sm')
|
||||||
* @param {boolean} props.showCount - 是否显示关注数(默认 true)
|
* @param {boolean} props.showCount - 是否显示关注数(默认 true)
|
||||||
* @param {string} props.variant - 样式变体('default' | 'minimal',默认 'default')
|
* @param {string} props.variant - 样式变体('default' | 'minimal',默认 'default')
|
||||||
|
* @param {string} props.layout - 布局方向('horizontal' | 'vertical',默认 'horizontal')
|
||||||
*/
|
*/
|
||||||
const EventFollowButton = ({
|
const EventFollowButton = ({
|
||||||
isFollowing,
|
isFollowing,
|
||||||
@@ -19,7 +20,8 @@ const EventFollowButton = ({
|
|||||||
onToggle,
|
onToggle,
|
||||||
size = 'sm',
|
size = 'sm',
|
||||||
showCount = true,
|
showCount = true,
|
||||||
variant = 'default'
|
variant = 'default',
|
||||||
|
layout = 'horizontal'
|
||||||
}) => {
|
}) => {
|
||||||
const iconSize = size === 'xs' ? '16px' : size === 'sm' ? '18px' : '22px';
|
const iconSize = size === 'xs' ? '16px' : size === 'sm' ? '18px' : '22px';
|
||||||
|
|
||||||
@@ -30,34 +32,38 @@ const EventFollowButton = ({
|
|||||||
|
|
||||||
// 最小样式 - 用于毛玻璃容器内
|
// 最小样式 - 用于毛玻璃容器内
|
||||||
if (variant === 'minimal') {
|
if (variant === 'minimal') {
|
||||||
|
const Stack = layout === 'vertical' ? VStack : HStack;
|
||||||
|
const isVertical = layout === 'vertical';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Tooltip label={isFollowing ? '取消关注' : '关注事件'} hasArrow placement="bottom">
|
<Tooltip label={isFollowing ? '取消关注' : '关注事件'} hasArrow placement="bottom">
|
||||||
<HStack
|
<Stack
|
||||||
as="button"
|
as="button"
|
||||||
spacing={1.5}
|
spacing={isVertical ? 0 : 1.5}
|
||||||
px={3}
|
px={isVertical ? 2 : 3}
|
||||||
py={1.5}
|
py={isVertical ? 1 : 1.5}
|
||||||
cursor="pointer"
|
cursor="pointer"
|
||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
|
align="center"
|
||||||
_hover={{ bg: 'rgba(255, 255, 255, 0.1)' }}
|
_hover={{ bg: 'rgba(255, 255, 255, 0.1)' }}
|
||||||
transition="all 0.2s"
|
transition="all 0.2s"
|
||||||
>
|
>
|
||||||
<Star
|
<Star
|
||||||
size={iconSize}
|
size={isVertical ? '14px' : iconSize}
|
||||||
color={isFollowing ? "#FFD700" : "#A0AEC0"}
|
color={isFollowing ? "#FFD700" : "#A0AEC0"}
|
||||||
fill={isFollowing ? "#FFD700" : "none"}
|
fill={isFollowing ? "#FFD700" : "none"}
|
||||||
style={{ transition: 'all 0.2s' }}
|
style={{ transition: 'all 0.2s' }}
|
||||||
/>
|
/>
|
||||||
{showCount && (
|
{showCount && (
|
||||||
<Text
|
<Text
|
||||||
fontSize="sm"
|
fontSize={isVertical ? "2xs" : "sm"}
|
||||||
fontWeight="semibold"
|
fontWeight="semibold"
|
||||||
color={isFollowing ? "yellow.400" : "white"}
|
color={isFollowing ? "yellow.400" : "gray.400"}
|
||||||
>
|
>
|
||||||
{followerCount || 0}
|
{followerCount || 0}
|
||||||
</Text>
|
</Text>
|
||||||
)}
|
)}
|
||||||
</HStack>
|
</Stack>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user