Skip to content

Commit 72d382b

Browse files
committed
feat(ui): update website components and styles - Enhance overall UI components - Update global styles and theme configurations
1 parent b7740f1 commit 72d382b

24 files changed

+3417
-282
lines changed

office-website/src/components/Community/QrCodeCard.tsx

Lines changed: 65 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import styled from 'styled-components';
3+
import Lightbox from 'yet-another-react-lightbox';
4+
import 'yet-another-react-lightbox/styles.css';
5+
import Zoom from 'yet-another-react-lightbox/plugins/zoom';
6+
import Counter from 'yet-another-react-lightbox/plugins/counter';
7+
import 'yet-another-react-lightbox/plugins/counter.css';
38

49
const QrCodeItem = styled.div`
510
display: flex;
@@ -23,6 +28,12 @@ const QrCodeImage = styled.img`
2328
height: auto;
2429
border-radius: 8px;
2530
margin-bottom: 1.5rem;
31+
cursor: pointer;
32+
transition: transform 0.2s ease;
33+
34+
&:hover {
35+
transform: scale(1.03);
36+
}
2637
`;
2738

2839
const QrCodeText = styled.p`
@@ -50,29 +61,68 @@ interface QrCodeCardProps {
5061
text: string;
5162
linkUrl?: string;
5263
linkText?: string;
64+
onClick?: () => void;
5365
}
5466

5567
const QrCodeCard: React.FC<QrCodeCardProps> = ({
5668
imageUrl,
5769
imageAlt,
5870
text,
5971
linkUrl,
60-
linkText
72+
linkText,
73+
onClick
6174
}) => {
75+
const [isOpen, setIsOpen] = useState(false);
76+
77+
const handleImageClick = () => {
78+
if (onClick) {
79+
onClick();
80+
} else {
81+
setIsOpen(true);
82+
}
83+
};
84+
6285
return (
63-
<QrCodeItem>
64-
<QrCodeImage src={imageUrl} alt={imageAlt} />
65-
<QrCodeText>
66-
{linkUrl && linkText ? (
67-
<>
68-
<StyledLink href={linkUrl} target="_blank">{linkText}</StyledLink>
69-
{" "}{text}
70-
</>
71-
) : (
72-
text
73-
)}
74-
</QrCodeText>
75-
</QrCodeItem>
86+
<>
87+
<QrCodeItem>
88+
<QrCodeImage
89+
src={imageUrl}
90+
alt={imageAlt}
91+
onClick={handleImageClick}
92+
title="点击查看大图"
93+
/>
94+
<QrCodeText>
95+
{linkUrl && linkText ? (
96+
<>
97+
<StyledLink href={linkUrl} target="_blank">{linkText}</StyledLink>
98+
{" "}{text}
99+
</>
100+
) : (
101+
text
102+
)}
103+
</QrCodeText>
104+
</QrCodeItem>
105+
106+
{!onClick && (
107+
<Lightbox
108+
open={isOpen}
109+
close={() => setIsOpen(false)}
110+
slides={[{ src: imageUrl, alt: imageAlt }]}
111+
plugins={[Zoom, Counter]}
112+
zoom={{
113+
maxZoomPixelRatio: 3,
114+
zoomInMultiplier: 1.5,
115+
}}
116+
carousel={{
117+
finite: true,
118+
}}
119+
render={{
120+
buttonPrev: () => null,
121+
buttonNext: () => null,
122+
}}
123+
/>
124+
)}
125+
</>
76126
);
77127
};
78128

office-website/src/components/Community/index.tsx

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
1-
import React from 'react';
1+
import React, { useState } from 'react';
22
import styled from 'styled-components';
3+
import Lightbox from 'yet-another-react-lightbox';
4+
import 'yet-another-react-lightbox/styles.css';
5+
import Zoom from 'yet-another-react-lightbox/plugins/zoom';
6+
import Counter from 'yet-another-react-lightbox/plugins/counter';
7+
import 'yet-another-react-lightbox/plugins/counter.css';
8+
import Thumbnails from 'yet-another-react-lightbox/plugins/thumbnails';
9+
import 'yet-another-react-lightbox/plugins/thumbnails.css';
310
import QrCodeCard from './QrCodeCard';
411
import { qrCodes } from './QrCodeData';
512

@@ -36,6 +43,22 @@ const QrCodesContainer = styled.div`
3643
`;
3744

3845
const Community: React.FC = () => {
46+
const [isOpen, setIsOpen] = useState(false);
47+
const [photoIndex, setPhotoIndex] = useState(0);
48+
49+
// 为Lightbox准备图片数据
50+
const slides = qrCodes.map(qrCode => ({
51+
src: qrCode.imageUrl,
52+
alt: qrCode.imageAlt,
53+
title: qrCode.text
54+
}));
55+
56+
// 处理打开Lightbox并设置初始图片
57+
const openLightbox = (index: number) => {
58+
setPhotoIndex(index);
59+
setIsOpen(true);
60+
};
61+
3962
return (
4063
<CommunityContainer id="community">
4164
<CommunityContent>
@@ -50,9 +73,28 @@ const Community: React.FC = () => {
5073
text={qrCode.text}
5174
linkUrl={qrCode.linkUrl}
5275
linkText={qrCode.linkText}
76+
onClick={() => openLightbox(index)}
5377
/>
5478
))}
5579
</QrCodesContainer>
80+
81+
{/* 全局图片查看器 */}
82+
<Lightbox
83+
open={isOpen}
84+
close={() => setIsOpen(false)}
85+
slides={slides}
86+
index={photoIndex}
87+
plugins={[Zoom, Counter, Thumbnails]}
88+
zoom={{
89+
maxZoomPixelRatio: 3,
90+
zoomInMultiplier: 1.5,
91+
}}
92+
thumbnails={{
93+
position: 'bottom',
94+
width: 120,
95+
height: 80,
96+
}}
97+
/>
5698
</CommunityContent>
5799
</CommunityContainer>
58100
);

0 commit comments

Comments
 (0)