-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
801 additions
and
505 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import React, { useEffect, useRef } from 'react'; | ||
import { Card } from 'antd'; | ||
import type { CardProps } from 'antd'; | ||
import styled from 'styled-components'; | ||
|
||
const CardContainer = styled(Card)` | ||
position: relative; | ||
z-index: 1; | ||
min-width: 300px; | ||
min-height: 50px; | ||
color: #fff; | ||
background-color: transparent; | ||
overflow: hidden; // 超出特效的区域隐藏掉 | ||
cursor: pointer; | ||
&:hover:after { | ||
width: 250px; | ||
height: 250px; | ||
left: var(--x); | ||
top: var(--y); | ||
} | ||
/* 鼠标hover光晕渐变 */ | ||
&:after { | ||
position: absolute; | ||
left: 50%; | ||
top: 50%; | ||
z-index: 6; | ||
transform: rotateX(-0.03deg) rotateY(-0.03deg) translate(-50%, -50%); | ||
transition: | ||
width 0.2s ease, | ||
height 0.2 ease; | ||
width: 0; | ||
height: 0; | ||
opacity: 0.7; | ||
content: ''; | ||
background: radial-gradient(circle closest-side, #133b71, transparent); | ||
} | ||
`; | ||
|
||
const Content = styled.div` | ||
position: relative; | ||
z-index: 5; | ||
width: 100%; | ||
height: 100%; | ||
`; | ||
|
||
const HoverCard = React.memo<CardProps>((props) => { | ||
const ref = useRef<HTMLDivElement>(null); | ||
const { children, ...restProps } = props; | ||
|
||
useEffect(() => { | ||
const containerRef = ref.current; | ||
const handleMouseMove = (event: MouseEvent) => { | ||
const targetRect = (event?.target as Element)?.getBoundingClientRect(); | ||
if (!targetRect || !containerRef) return; | ||
const xPosition = event.clientX - targetRect.left; | ||
const yPosition = event.clientY - targetRect.top; | ||
containerRef.style.setProperty('--x', xPosition + 'px'); | ||
containerRef.style.setProperty('--y', yPosition + 'px'); | ||
}; | ||
containerRef?.addEventListener('mousemove', handleMouseMove); | ||
return () => { | ||
containerRef?.removeEventListener('mousemove', handleMouseMove); | ||
}; | ||
}, []); | ||
|
||
return ( | ||
<div ref={ref} style={{ display: 'inline-block', flex: 1 }}> | ||
<CardContainer {...restProps}> | ||
<Content>{children}</Content> | ||
</CardContainer> | ||
</div> | ||
); | ||
}); | ||
|
||
export default HoverCard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
import { useIntl } from '../../hooks/useIntl'; | ||
import HoverCard from './HoverCard'; | ||
import { Flex, Typography } from 'antd'; | ||
|
||
const { Text } = Typography; | ||
|
||
const FlexContainer = styled(Flex)` | ||
display: flex; | ||
flex-wrap: wrap; | ||
max-width: min(1200px, 90%); | ||
gap: 24px; | ||
margin: 0 auto; | ||
@media (max-width: 900px), (max-width: 480px) { | ||
gap: 16px; | ||
flex-direction: column; | ||
} | ||
`; | ||
|
||
const HoverCardContainer = styled(HoverCard)` | ||
height: 100%; | ||
border: none; | ||
background-image: linear-gradient( | ||
106deg, | ||
rgba(255, 255, 255, 0.12) 0%, | ||
rgba(255, 255, 255, 0.1) 100% | ||
); | ||
border-radius: 16px; | ||
.openagl-card-body { | ||
height: 100%; | ||
@media (max-width: 900px) { | ||
padding: 16px; | ||
} | ||
@media (max-width: 480px) { | ||
padding: 12px; | ||
} | ||
} | ||
`; | ||
|
||
const Title = styled(Flex)` | ||
overflow: hidden; | ||
align-items: center; | ||
justify-content: center; | ||
gap: 8px; | ||
opacity: 0.95; | ||
font-weight: 500; | ||
`; | ||
|
||
const Description = styled(Text)` | ||
display: inline-block; | ||
width: 100%; | ||
font-size: 14px; | ||
font-weight: 400; | ||
opacity: 0.45; | ||
margin-top: 9px; | ||
text-align: center; | ||
`; | ||
|
||
const Announcement = React.memo(() => { | ||
const { | ||
Messages: { ANNOUNCEMENT }, | ||
} = useIntl(); | ||
|
||
const handleOpenLink = (linkUrl?: string) => { | ||
if (!linkUrl) return; | ||
window.open(linkUrl, '_blank', 'noopener=yes,noreferrer=yes'); | ||
}; | ||
|
||
if (ANNOUNCEMENT.length === 0) { | ||
return <div style={{ padding: 20 }} />; | ||
} | ||
|
||
return ( | ||
<FlexContainer justify="space-between"> | ||
{ANNOUNCEMENT.map(({ cover, title, description, link }) => ( | ||
<HoverCardContainer key={title} onClick={() => handleOpenLink(link)}> | ||
<Title> | ||
<img src={cover} /> | ||
<span>{title}</span> | ||
</Title> | ||
<Description>{description}</Description> | ||
</HoverCardContainer> | ||
))} | ||
</FlexContainer> | ||
); | ||
}); | ||
|
||
export default Announcement; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.