new
This commit is contained in:
244
frontend/src/components/activity/Activity.module.less
Normal file
244
frontend/src/components/activity/Activity.module.less
Normal file
@@ -0,0 +1,244 @@
|
||||
@import '../../styles/theme.less';
|
||||
|
||||
.container {
|
||||
padding: 24px 0;
|
||||
max-width: 1200px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.sectionHeader {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-bottom: 24px;
|
||||
padding: 0 24px;
|
||||
|
||||
.sectionTitle {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: @text-color;
|
||||
letter-spacing: 1px;
|
||||
}
|
||||
|
||||
.moreBtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
cursor: pointer;
|
||||
color: @primary-color;
|
||||
transition: all 0.3s;
|
||||
|
||||
&:hover {
|
||||
color: lighten(@primary-color, 10%);
|
||||
transform: translateX(4px);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.card {
|
||||
position: relative;
|
||||
border-radius: @border-radius-base;
|
||||
overflow: hidden;
|
||||
aspect-ratio: 16/9;
|
||||
cursor: pointer;
|
||||
background: @card-bg;
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
|
||||
@media (max-width: 768px) {
|
||||
aspect-ratio: 3/4;
|
||||
}
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
transition: transform 0.5s ease;
|
||||
}
|
||||
|
||||
.overlay {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 60%;
|
||||
background: linear-gradient(to top, rgba(0,0,0,0.9), transparent);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
padding: 24px;
|
||||
}
|
||||
|
||||
.status {
|
||||
display: inline-block;
|
||||
padding: 4px 12px;
|
||||
background: @primary-color;
|
||||
color: #000;
|
||||
font-size: 12px;
|
||||
font-weight: bold;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 8px;
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
.title {
|
||||
font-size: 24px;
|
||||
font-weight: bold;
|
||||
color: @text-color;
|
||||
margin-bottom: 8px;
|
||||
text-shadow: 0 2px 4px rgba(0,0,0,0.5);
|
||||
}
|
||||
|
||||
.time {
|
||||
font-size: 14px;
|
||||
color: @text-secondary;
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.image {
|
||||
transform: scale(1.05);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Detail Page
|
||||
.detailContainer {
|
||||
min-height: 100vh;
|
||||
background: @bg-color;
|
||||
color: @text-color;
|
||||
padding-bottom: 80px;
|
||||
}
|
||||
|
||||
.heroSection {
|
||||
position: relative;
|
||||
height: 50vh;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
|
||||
.heroImage {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.backBtn {
|
||||
position: absolute;
|
||||
top: 24px;
|
||||
left: 24px;
|
||||
z-index: 10;
|
||||
background: rgba(0,0,0,0.5);
|
||||
border: none;
|
||||
color: white;
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
backdrop-filter: blur(4px);
|
||||
|
||||
&:hover {
|
||||
background: rgba(0,0,0,0.7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.contentSection {
|
||||
padding: 24px;
|
||||
max-width: 800px;
|
||||
margin: 0 auto;
|
||||
margin-top: -60px;
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
background: rgba(30, 30, 30, 0.8);
|
||||
backdrop-filter: blur(20px);
|
||||
border-radius: 24px 24px 0 0;
|
||||
border-top: 1px solid rgba(255,255,255,0.1);
|
||||
}
|
||||
|
||||
.metaInfo {
|
||||
margin-bottom: 32px;
|
||||
|
||||
h1 {
|
||||
font-size: 32px;
|
||||
margin-bottom: 16px;
|
||||
color: @text-color;
|
||||
}
|
||||
}
|
||||
|
||||
.infoRow {
|
||||
display: flex;
|
||||
gap: 24px;
|
||||
margin-bottom: 16px;
|
||||
color: @text-secondary;
|
||||
|
||||
.icon {
|
||||
margin-right: 8px;
|
||||
color: @primary-color;
|
||||
}
|
||||
}
|
||||
|
||||
.richText {
|
||||
line-height: 1.8;
|
||||
color: #ddd;
|
||||
font-size: 16px;
|
||||
|
||||
img {
|
||||
max-width: 100%;
|
||||
border-radius: 8px;
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
h2, h3 {
|
||||
color: @text-color;
|
||||
margin-top: 24px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
}
|
||||
|
||||
.bottomBar {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
padding: 16px 24px;
|
||||
background: rgba(20, 20, 20, 0.9);
|
||||
backdrop-filter: blur(10px);
|
||||
border-top: 1px solid rgba(255,255,255,0.1);
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
z-index: 100;
|
||||
|
||||
.actionBtn {
|
||||
flex: 1;
|
||||
margin-left: 16px;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
font-weight: bold;
|
||||
border: none;
|
||||
background: @primary-color;
|
||||
box-shadow: 0 4px 12px rgba(0, 185, 107, 0.3);
|
||||
|
||||
&:hover {
|
||||
background: lighten(@primary-color, 5%);
|
||||
}
|
||||
}
|
||||
|
||||
.shareBtn {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
border-radius: 50%;
|
||||
border: 1px solid rgba(255,255,255,0.2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
|
||||
&:hover {
|
||||
background: rgba(255,255,255,0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
frontend/src/components/activity/ActivityCard.jsx
Normal file
42
frontend/src/components/activity/ActivityCard.jsx
Normal file
@@ -0,0 +1,42 @@
|
||||
import React from 'react';
|
||||
import { motion } from 'framer-motion';
|
||||
import { Typography } from 'antd';
|
||||
import { CalendarOutlined } from '@ant-design/icons';
|
||||
import { cardHover } from '../../animation';
|
||||
import styles from './activity.module.less';
|
||||
|
||||
const { Text } = Typography;
|
||||
|
||||
const ActivityCard = ({ activity, onClick, layoutId }) => {
|
||||
const { title, start_time, display_banner_url, banner_url, cover_image, status = '报名中' } = activity;
|
||||
const imageUrl = display_banner_url || banner_url || cover_image || 'https://via.placeholder.com/600x300';
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className={styles.card}
|
||||
variants={cardHover}
|
||||
whileHover="hover"
|
||||
onClick={onClick}
|
||||
layoutId={layoutId}
|
||||
>
|
||||
<motion.img
|
||||
src={imageUrl}
|
||||
alt={title}
|
||||
className={styles.image}
|
||||
loading="lazy"
|
||||
/>
|
||||
<div className={styles.overlay}>
|
||||
<div className={styles.info}>
|
||||
<span className={styles.status}>{status}</span>
|
||||
<h3 className={styles.title}>{title}</h3>
|
||||
<div className={styles.time}>
|
||||
<CalendarOutlined style={{ marginRight: 8 }} />
|
||||
{start_time ? start_time.split('T')[0] : 'TBD'}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ActivityCard;
|
||||
72
frontend/src/components/activity/ActivityList.jsx
Normal file
72
frontend/src/components/activity/ActivityList.jsx
Normal file
@@ -0,0 +1,72 @@
|
||||
import React from 'react';
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Carousel } from 'antd';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { RightOutlined } from '@ant-design/icons';
|
||||
import { getActivities } from '../../api';
|
||||
import ActivityCard from './ActivityCard';
|
||||
import styles from './activity.module.less';
|
||||
import { motion } from 'framer-motion';
|
||||
import { fadeInUp } from '../../animation';
|
||||
|
||||
const ActivityList = () => {
|
||||
const navigate = useNavigate();
|
||||
const { data: activities, isLoading } = useQuery({
|
||||
queryKey: ['activities'],
|
||||
queryFn: async () => {
|
||||
try {
|
||||
const res = await getActivities();
|
||||
return Array.isArray(res) ? res : (res?.results || res?.data || []);
|
||||
} catch (e) {
|
||||
console.error("Failed to fetch activities", e);
|
||||
return [];
|
||||
}
|
||||
},
|
||||
staleTime: 1000 * 60 * 5, // Cache for 5 mins
|
||||
});
|
||||
|
||||
if (isLoading || !activities || activities.length === 0) return null;
|
||||
|
||||
const goToDetail = (id) => {
|
||||
navigate(`/activity/${id}`);
|
||||
};
|
||||
|
||||
return (
|
||||
<motion.div
|
||||
className={styles.container}
|
||||
initial="initial"
|
||||
whileInView="animate"
|
||||
viewport={{ once: true, margin: "-100px" }}
|
||||
variants={fadeInUp}
|
||||
>
|
||||
<div className={styles.sectionHeader}>
|
||||
<div className={styles.sectionTitle}>近期活动 / EVENTS</div>
|
||||
<div className={styles.moreBtn} onClick={() => navigate('/activity/list')}>
|
||||
<span>MORE</span>
|
||||
<RightOutlined />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Carousel
|
||||
autoplay
|
||||
autoplaySpeed={5000}
|
||||
effect="scrollx"
|
||||
slidesToShow={1}
|
||||
dots={true}
|
||||
className={styles.carousel}
|
||||
>
|
||||
{activities.map(item => (
|
||||
<div key={item.id} className={styles.slideItem}>
|
||||
<ActivityCard
|
||||
activity={item}
|
||||
onClick={() => goToDetail(item.id)}
|
||||
layoutId={`activity-${item.id}`}
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</Carousel>
|
||||
</motion.div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ActivityList;
|
||||
Reference in New Issue
Block a user