Skip to content

Commit

Permalink
Add beta invitation banner (#2208)
Browse files Browse the repository at this point in the history
This adds a banner to the bottom of the page that links to the beta on staging.simplenote.com.
  • Loading branch information
codebykat authored Aug 4, 2020
1 parent 23415b1 commit 2ea1d3d
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import browserShell from './browser-shell';
import NoteInfo from './note-info';
import NavigationBar from './navigation-bar';
import AppLayout from './app-layout';
import BetaBar from './components/beta-bar';
import DevBadge from './components/dev-badge';
import DialogRenderer from './dialog-renderer';
import exportZipArchive from './utils/export';
Expand Down Expand Up @@ -452,6 +453,7 @@ export const App = connect(
return (
<div className={appClasses}>
{isDevConfig && <DevBadge />}
<BetaBar />
<div className={mainClasses}>
{showNavigation && <NavigationBar />}
<AppLayout
Expand Down
44 changes: 44 additions & 0 deletions lib/components/beta-bar/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useState } from 'react';
import SmallCrossIcon from '../../icons/cross-small';
import { isElectron } from '../../utils/platform';

const loadOptOut = (): boolean => {
try {
const stored = localStorage.getItem('betaBannerDismissedAt');
const dismissedAt = stored ? parseInt(stored, 10) : -Infinity;

return (
isNaN(dismissedAt) || Date.now() - dismissedAt > 7 * 24 * 60 * 60 * 1000
);
} catch (e) {
return true;
}
};

const storeOptOut = () => {
try {
localStorage.setItem('betaBannerDismissedAt', Date.now().toString());
} catch (e) {
// pass
}
};

const BetaBar = () => {
const [isVisible, setIsVisible] = useState(loadOptOut());
const dismissBanner = () => {
storeOptOut();
setIsVisible(false);
};

return !isElectron && isVisible ? (
<div className="beta-bar">
You&lsquo;re invited to try Simplenote Beta.
<a href="https://staging.simplenote.com">Try it now.</a>
<a className="icon" onClick={dismissBanner}>
<SmallCrossIcon />
</a>
</div>
) : null;
};

export default BetaBar;
23 changes: 23 additions & 0 deletions lib/components/beta-bar/style.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.beta-bar {
position: absolute;
width: 100%;
height: 36px;
bottom: 0;
box-shadow: 0 2px 7px 0 rgba(0, 0, 0, 0.2);
background-color: #3d3f41;
color: #fff;
text-align: center;
line-height: 32px;
z-index: 1;

a {
color: #fff !important;
margin-left: 5px;
}
svg {
position: absolute;
right: 12px;
bottom: 7px;
cursor: pointer;
}
}
1 change: 1 addition & 0 deletions scss/_components.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import 'app-layout/style';
@import 'auth/style';
@import 'components/checkbox/style';
@import 'components/beta-bar/style';
@import 'components/dev-badge/style';
@import 'components/panel-title/style';
@import 'components/progress-bar/style';
Expand Down

0 comments on commit 2ea1d3d

Please sign in to comment.