-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add temporary AMS banner in homepage (#270)
* Work on AMS banner * Add tempBanner info in config * Add tempbanner string * Change padding * Change banner link color to white * Update version * Update link to the specific course * Fix a grammar error --------- Co-authored-by: Hanbyul Jo <[email protected]>
- Loading branch information
1 parent
8fcf1c5
commit 33452e4
Showing
5 changed files
with
91 additions
and
3 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
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,81 @@ | ||
import React, { useState } from '$veda-ui/react' | ||
import { Button } from "$veda-ui/@devseed-ui/button"; | ||
import { CollecticonXmarkSmall } from "$veda-ui/@devseed-ui/collecticons"; | ||
import styled from '$veda-ui/styled-components'; | ||
import { | ||
glsp, | ||
media, | ||
themeVal | ||
} from '$veda-ui/@devseed-ui/theme-provider'; | ||
import Hug from "$veda-ui-scripts/styles/hug"; | ||
import { getString } from 'veda'; | ||
|
||
const AMS_BANNER_KEY = 'show-ams-banner' | ||
|
||
const BannerBox = styled.div` | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
z-index: 1000; | ||
background-color: #C75D61; | ||
text-align: center; | ||
font-size: 1rem; | ||
a { | ||
color: ${themeVal('color.surface')}; | ||
} | ||
` | ||
|
||
const BannerContainer = styled(Hug)` | ||
width: 100%; | ||
padding: ${glsp(0, 0.25)}; | ||
${media.mediumDown` | ||
padding: ${glsp(0.25, 0.25)}; | ||
`} | ||
`; | ||
|
||
const BannerContent = styled.div` | ||
grid-column: content-start / content-end; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
text-align: center; | ||
font-weight: 600; | ||
${media.mediumDown` | ||
text-align: left; | ||
font-size: 0.75rem; | ||
`} | ||
a:link, a:visited { | ||
color: white; | ||
} | ||
` | ||
|
||
export default function Banner() { | ||
const showBanner = (localStorage.getItem(AMS_BANNER_KEY) !== 'false') && !!getString('tempBanner')?.other | ||
const [ showTempBanner, setShowTempBanner ] = useState(showBanner); | ||
|
||
function onClick () { | ||
localStorage.setItem( | ||
AMS_BANNER_KEY, | ||
'false' | ||
); | ||
setShowTempBanner(false); | ||
} | ||
|
||
return (showTempBanner && | ||
<BannerBox className="banner"> | ||
<BannerContainer> | ||
<BannerContent> | ||
<a href={getString('tempBannerUrl')?.other || "" } target="_blank"> | ||
{ getString('tempBanner').other } | ||
</a> | ||
<Button onClick={onClick} variation="base-text" fitting="skinny"> | ||
<CollecticonXmarkSmall title="Dismiss banner" color="white" meaningful /> | ||
</Button> | ||
</BannerContent> | ||
</BannerContainer> | ||
</BannerBox> | ||
) | ||
} |
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
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
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