-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
442: Add a call to action banner for the cloud r=bidoubiwa a=bidoubiwa Fixes: #441 A banner now automatically appears at the top of the page with a call to action to the Meilisearch cloud. To deactivate the banner, you can add `cloud_banner=false` to the query parameters. ## TODO: - [x] Implement banner - [x] Implement query param - [x] Implement caching of banner visibility Co-authored-by: Charlotte Vermandel <charlottevermandel@gmail.com> Co-authored-by: cvermand <33010418+bidoubiwa@users.noreply.github.com>
- Loading branch information
Showing
5 changed files
with
123 additions
and
2 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
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,91 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import Color from 'color' | ||
import Typography from 'components/Typography' | ||
import Link from 'components/Link' | ||
|
||
import IconButton from 'components/IconButton' | ||
import { Cross } from 'components/icons' | ||
import Container from './Container' | ||
|
||
const Button = styled(IconButton)` | ||
position: absolute; | ||
top: 27px; | ||
right: 16px; | ||
&:hover { | ||
pointer-events: initial; | ||
} | ||
` | ||
|
||
const CloudBannerWrapper = styled.div` | ||
background: linear-gradient(269.85deg, #ff1786 0%, #8e33de 100%); | ||
display: flex; | ||
position: sticky; | ||
top: 0; | ||
height: 74px; | ||
box-shadow: 0px 0px 30px ${(p) => Color(p.theme.colors.gray[0]).alpha(0.15)}; | ||
z-index: 3; | ||
padding: 4px; | ||
` | ||
|
||
const CloudBanner = () => { | ||
const [isBannerVisible, setIsBannerVisible] = React.useState(true) | ||
|
||
const handleBannerClose = () => { | ||
setIsBannerVisible(false) | ||
localStorage.setItem('bannerVisibility', JSON.stringify(false)) | ||
} | ||
|
||
// Retrieve the banner visibility state from local storage on component mount | ||
React.useEffect(() => { | ||
const storedVisibility = localStorage.getItem('bannerVisibility') | ||
if (storedVisibility) { | ||
setIsBannerVisible(JSON.parse(storedVisibility)) | ||
} | ||
|
||
return () => {} | ||
}, []) | ||
|
||
return ( | ||
<> | ||
{isBannerVisible && ( | ||
<CloudBannerWrapper> | ||
<Container | ||
display="flex" | ||
flexDirection="column" | ||
alignContent="center" | ||
> | ||
<Typography variant="typo14" color="white"> | ||
Supercharge your Meilisearch experience | ||
</Typography> | ||
|
||
<Typography variant="typo15" color="white"> | ||
Say goodbye to server management, and manual updates with{' '} | ||
<Link | ||
href="https://www.meilisearch.com/pricing?utm_campaign=oss&utm_source=integration&utm_medium=minidashboard" | ||
color="white" | ||
> | ||
<Typography variant="typo14" color="white"> | ||
Meilisearch Cloud | ||
</Typography> | ||
</Link> | ||
. | ||
<Typography variant="typo14" color="white"> | ||
Get started with a 14-day free trial! No credit card required. | ||
</Typography> | ||
</Typography> | ||
<Button | ||
color="gray.9" | ||
aria-label="close" | ||
onClick={handleBannerClose} | ||
> | ||
<Cross style={{ width: 10 }} /> | ||
</Button> | ||
</Container> | ||
</CloudBannerWrapper> | ||
)} | ||
</> | ||
) | ||
} | ||
|
||
export default CloudBanner |
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