Skip to content

Commit

Permalink
docs: add app.js banner (#4183)
Browse files Browse the repository at this point in the history
## Summary

This PR adds banner announcing app.js conf. 

The banner is easily dismissable and will disappear automatically after
the conference.

### Screenshots

##### X Large screen


![image](https://user-images.githubusercontent.com/39658211/223506267-de56f51f-e517-477c-ae31-5aaad293a629.png)

##### Large screen

<img width="721" alt="image"
src="https://user-images.githubusercontent.com/39658211/223506461-b92c6a1f-1794-4a6f-ae54-01436bdcd729.png">


##### Tablet



![image](https://user-images.githubusercontent.com/39658211/223508037-c192d3f2-039f-496c-8e59-9063546723f9.png)


##### Mobile


![image](https://user-images.githubusercontent.com/39658211/223508080-f678c7df-1c84-4834-be74-a5f123eadb7a.png)
  • Loading branch information
kacperkapusciak authored Mar 8, 2023
1 parent 6abbdc7 commit 79b699a
Show file tree
Hide file tree
Showing 8 changed files with 355 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,12 @@ module.exports = {
prism: {
theme: prismConfig,
},
announcementBar: {
id: 'appjs_announcement',
content: 'mleko', // content is set in swizzled component but docusaurus requires it to be non-empty
backgroundColor: '#0033CC',
textColor: '#FFFFFF',
},
},
presets: [
[
Expand Down
20 changes: 20 additions & 0 deletions docs/src/theme/AnnouncementBar/CloseButton/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';
import clsx from 'clsx';
import { translate } from '@docusaurus/Translate';
import IconClose from '@theme/Icon/Close';
import styles from './styles.module.css';
export default function AnnouncementBarCloseButton(props) {
return (
<button
type="button"
aria-label={translate({
id: 'theme.AnnouncementBar.closeButtonAriaLabel',
message: 'Close',
description: 'The ARIA label for close button of announcement bar',
})}
{...props}
className={clsx('clean-btn close', styles.closeButton, props.className)}>
<IconClose width={14} height={14} strokeWidth={3.1} />
</button>
);
}
19 changes: 19 additions & 0 deletions docs/src/theme/AnnouncementBar/CloseButton/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
.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;
}
}
23 changes: 23 additions & 0 deletions docs/src/theme/AnnouncementBar/Content/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import clsx from 'clsx';
import styles from './styles.module.css';

export default function AnnouncementBarContent(props) {
return (
<div {...props} className={clsx(styles.content, props.className)}>
<div className={styles.wrapper}>
<strong className={styles.headline}>We're organizing app.js</strong>
<p className={styles.subText}>
a React Native & Expo-focused conference
</p>
</div>
<a
className={styles.link}
href="https://appjs.co/"
target="_blank"
rel="noreferrer noopener">
Learn more
</a>
</div>
);
}
69 changes: 69 additions & 0 deletions docs/src/theme/AnnouncementBar/Content/styles.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.content {
display: flex;
align-items: center;
justify-content: space-between;
margin: 0 auto;
max-width: 1440px;

padding: 10px 0;
}

.content a {
color: inherit;
text-decoration: underline;
}
.wrapper {
display: flex;
align-items: flex-end;
justify-content: center;
}

.headline {
margin-right: 8px;
}

.subText {
margin: 0;
}

.subText::before {
content: ' - ';
}

.link {
font-size: 20px;
}

@media screen and (max-width: 996px) {
.content {
flex-direction: column;
align-items: flex-start;
padding: 20px 24px;
}
.wrapper {
flex-direction: column;
align-items: flex-start;
margin-bottom: 8px;
}
.headline,
.subText {
font-size: 20px;
}

.subText::before {
content: '';
}
.link {
font-size: 16px;
}
}
@media screen and (max-width: 600px) {
.headline,
.subText {
font-size: 16px;
}

.link {
font-size: 14px;
}
}
48 changes: 48 additions & 0 deletions docs/src/theme/AnnouncementBar/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import React 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 styles from './styles.module.css';
import Particles from './particles.svg';

export default function AnnouncementBar() {
const { announcementBar } = useThemeConfig();
const { isActive, close } = useAnnouncementBar();
if (!isActive) {
return null;
}
const { backgroundColor, textColor, isCloseable } = announcementBar;

// hide announcement bar after app.js
const today = new Date();
const endOfAppJS = new Date('2023-05-13T00:00:00.000Z');
if (today > endOfAppJS) {
return null;
}

return (
<div
className={styles.announcementBar}
style={{
backgroundColor,
color: textColor,
}}
role="banner">
<Particles
className={`${styles.announcementBarAdornment} ${styles.announcementBarLeftAdornment}`}
/>
{isCloseable && <div className={styles.announcementBarPlaceholder} />}
<AnnouncementBarContent className={styles.announcementBarContent} />
{isCloseable && (
<AnnouncementBarCloseButton
onClick={close}
className={styles.announcementBarClose}
/>
)}
<Particles
className={`${styles.announcementBarAdornment} ${styles.announcementBarRightAdornment}`}
/>
</div>
);
}
Loading

0 comments on commit 79b699a

Please sign in to comment.