-
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.
Merge pull request #21 from pepe1113/feature/donate_link
Add donate promotion bar
- Loading branch information
Showing
2 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
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,74 @@ | ||
import { useState, useEffect } from 'react'; | ||
import styled from '@emotion/styled'; | ||
|
||
const PromotionBarWrapper = styled.div` | ||
background-color: #f37b5f; | ||
color: #fff; | ||
padding: 7px; | ||
text-align: center; | ||
font-size: 16px; | ||
a:hover { | ||
text-decoration: underline; | ||
text-underline-offset: 3px; | ||
} | ||
`; | ||
|
||
const CloseButton = styled.span` | ||
position: absolute; | ||
top: 9px; | ||
right: 7px; | ||
width: 20px; | ||
height: 20px; | ||
opacity: 0.3; | ||
cursor: pointer; | ||
&:hover { | ||
opacity: 1; | ||
} | ||
&:before, | ||
&:after { | ||
position: absolute; | ||
left: 10px; | ||
content: ' '; | ||
height: 20px; | ||
width: 2px; | ||
background-color: #333; | ||
} | ||
&:before { | ||
transform: rotate(45deg); | ||
} | ||
&:after { | ||
transform: rotate(-45deg); | ||
} | ||
`; | ||
|
||
const PromotionBar = ({ link, text }) => { | ||
const [show, setShow] = useState(undefined); | ||
|
||
useEffect(() => { | ||
setShow(true); | ||
}, []); | ||
|
||
const handleClose = () => { | ||
setShow(false); | ||
}; | ||
|
||
return ( | ||
<> | ||
{show && ( | ||
<PromotionBarWrapper> | ||
<a href={link} target="_blank" rel="noreferrer"> | ||
{text} | ||
</a> | ||
<CloseButton onClick={handleClose} /> | ||
</PromotionBarWrapper> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default PromotionBar; |
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
0e7240f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
daodao-f2e – ./
daodao-f2e.vercel.app
daodao-f2e-git-dev-daodaoedu.vercel.app
daodao-f2e-daodaoedu.vercel.app