-
-
Notifications
You must be signed in to change notification settings - Fork 980
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add closable App.js banner to docs landing page (#2781)
<img width="1194" alt="image" src="https://github.com/software-mansion/react-native-gesture-handler/assets/59940332/71db5db8-d285-4888-b041-f8a5c17e8b9c">
- Loading branch information
1 parent
20acebf
commit d55d8de
Showing
12 changed files
with
197 additions
and
236 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
15 changes: 0 additions & 15 deletions
15
docs/src/theme/AnnouncementBar/CloseButton/styles.module.css
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 |
---|---|---|
@@ -1,19 +1,4 @@ | ||
.closeButton { | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
padding: 0; | ||
line-height: 0; | ||
z-index: 1; | ||
} | ||
|
||
.closeButton svg { | ||
color: white; | ||
} | ||
|
||
@media screen and (max-width: 996px) { | ||
.closeButton { | ||
align-items: flex-start; | ||
padding: 24px; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
docs/src/theme/AnnouncementBar/Content/ArrowButton/index.js
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,22 @@ | ||
import React from 'react'; | ||
|
||
function ArrowButton({ className }) { | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
fill="none" | ||
stroke="currentColor" | ||
className={className} | ||
viewBox="0 0 24 24"> | ||
<g> | ||
<path | ||
strokeLinecap="round" | ||
strokeLinejoin="round" | ||
strokeWidth="2" | ||
d="M7 17L17 7m0 0H7m10 0v10"></path> | ||
</g> | ||
</svg> | ||
); | ||
} | ||
|
||
export default ArrowButton; |
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,28 @@ | ||
import React from 'react'; | ||
import clsx from 'clsx'; | ||
import ArrowButton from './ArrowButton'; | ||
import styles from './styles.module.css'; | ||
|
||
export default function AnnouncementBarContent(props) { | ||
return ( | ||
<div className={clsx(styles.content, props.className)}> | ||
<div className={styles.wrapper}> | ||
<strong className={styles.headline}>App.js Conf 2024</strong> | ||
<p className={styles.subText}> | ||
An Expo & React Native conference in Europe is back, May 22-24 in | ||
Kraków, Poland! | ||
</p> | ||
</div> | ||
<a | ||
className={styles.link} | ||
href="https://appjs.co/" | ||
target="_blank" | ||
rel="noreferrer noopener"> | ||
<span className={styles.linkTitle}>Learn More</span> | ||
<div className={styles.linkArrowContainer}> | ||
<ArrowButton className={styles.linkArrow} /> | ||
</div> | ||
</a> | ||
</div> | ||
); | ||
} |
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
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,73 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useThemeConfig } from '@docusaurus/theme-common'; | ||
import { useAnnouncementBar } from '@docusaurus/theme-common/internal'; | ||
import AnnouncementBarCloseButton from '@theme/AnnouncementBar/CloseButton'; | ||
import AnnouncementBarContent from '@theme/AnnouncementBar/Content'; | ||
import BrowserOnly from '@docusaurus/BrowserOnly'; | ||
import styles from './styles.module.css'; | ||
|
||
function AnnouncementBar() { | ||
const { announcementBar } = useThemeConfig(); | ||
const { isActive, close } = useAnnouncementBar(); | ||
const [isPageLoaded, setIsPageLoaded] = useState( | ||
document.readyState === 'complete' | ||
); | ||
|
||
useEffect(() => { | ||
const handlePageLoad = () => { | ||
setIsPageLoaded(true); | ||
}; | ||
|
||
if (document.readyState === 'complete') { | ||
setIsPageLoaded(true); | ||
} else { | ||
window.addEventListener('load', handlePageLoad); | ||
} | ||
|
||
return () => { | ||
window.removeEventListener('load', handlePageLoad); | ||
}; | ||
}, []); | ||
|
||
if (!isPageLoaded || !isActive) { | ||
return null; | ||
} | ||
|
||
// hide announcement bar after app.js | ||
const today = new Date(); | ||
const endOfAppJS = new Date('2024-05-25T00:00:00.000Z'); | ||
if (today > endOfAppJS) { | ||
return null; | ||
} | ||
|
||
const { backgroundColor, textColor, isCloseable } = announcementBar; | ||
return ( | ||
<BrowserOnly fallback={<div>Loading...</div>}> | ||
{() => ( | ||
<div | ||
className={styles.announcementBar} | ||
style={{ backgroundColor, color: textColor }} | ||
role="banner"> | ||
{isCloseable && <div className={styles.announcementBarPlaceholder} />} | ||
<AnnouncementBarContent className={styles.announcementBarContent} /> | ||
{isCloseable && ( | ||
<div className={styles.buttonContainer}> | ||
<AnnouncementBarCloseButton | ||
onClick={close} | ||
className={styles.announcementBarClose} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
)} | ||
</BrowserOnly> | ||
); | ||
} | ||
|
||
export default function HOCAnnouncementBar() { | ||
return ( | ||
<BrowserOnly fallback={<div></div>}> | ||
{() => <AnnouncementBar />} | ||
</BrowserOnly> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.