-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app-general): add google chrome suggestion banner
- Loading branch information
Showing
5 changed files
with
97 additions
and
1 deletion.
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
26 changes: 26 additions & 0 deletions
26
packages/game-app/src/_shared/components/PersistentBanner/PersistentBanner.styled.tsx
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,26 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Banner = styled.div` | ||
position: absolute; | ||
z-index: 1000; | ||
left: 50px; | ||
right: 50px; | ||
bottom: 16px; | ||
height: 50px; | ||
background: #d7d2cb; | ||
border-radius: 10px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
align-items: center; | ||
`; | ||
|
||
Banner.displayName = 'Banner'; | ||
|
||
export const CloseIconWrapper = styled.div` | ||
position: absolute; | ||
right: 4px; | ||
top: 4px; | ||
`; | ||
|
||
CloseIconWrapper.displayName = 'CloseIconWrapper'; |
45 changes: 45 additions & 0 deletions
45
packages/game-app/src/_shared/components/PersistentBanner/PersistentBanner.tsx
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,45 @@ | ||
import React, { useCallback, useState } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import { Banner, CloseIconWrapper } from './PersistentBanner.styled'; | ||
import { ReactComponent as ClearIcon } from '../../../assets/icons/clear-search.svg'; | ||
import IconButton from '../IconButton'; | ||
|
||
type Props = { | ||
key: string; | ||
}; | ||
|
||
// todo do we have to persist the closed banner? | ||
const PersistentBanner: React.FC<Props> = ({ key, children }) => { | ||
const [visible, setVisible] = useState<boolean | null>(true); | ||
|
||
const close = useCallback(() => { | ||
setVisible(false); | ||
// localStorage.setItem(`bannerClosed:${key}`, 'true'); | ||
//}, [key]) | ||
}, []); | ||
|
||
/* for persistence | ||
useEffect(() => { | ||
const bannerClosed = localStorage.getItem(`bannerClosed:${key}`); | ||
setVisible(!(bannerClosed === 'true')) | ||
}, [key]) | ||
*/ | ||
|
||
return visible | ||
? createPortal( | ||
<Banner> | ||
<CloseIconWrapper> | ||
<IconButton variant="clearSmall" onClick={close}> | ||
<ClearIcon /> | ||
</IconButton> | ||
</CloseIconWrapper> | ||
{children} | ||
</Banner>, | ||
document.body, | ||
) | ||
: null; | ||
}; | ||
|
||
PersistentBanner.displayName = 'PersistentBanner'; | ||
|
||
export default PersistentBanner; |
3 changes: 3 additions & 0 deletions
3
packages/game-app/src/_shared/components/PersistentBanner/index.ts
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,3 @@ | ||
import PersistentBanner from './PersistentBanner'; | ||
|
||
export default PersistentBanner; |
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