Skip to content

Commit

Permalink
feat(ui): move about page to modal box
Browse files Browse the repository at this point in the history
  • Loading branch information
ncarlier committed Mar 19, 2020
1 parent 816aff7 commit 003d31c
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 48 deletions.
36 changes: 0 additions & 36 deletions ui/src/about/AboutPage.tsx

This file was deleted.

2 changes: 0 additions & 2 deletions ui/src/routes.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from 'react'
import { Redirect, Route, Switch } from 'react-router-dom'

import AboutPage from './about/AboutPage'
import ArticlesRoutes from './articles/Routes'
import CategoryRoutes from './categories/Routes'
import ErrorPage from './error/ErrorPage'
Expand All @@ -18,7 +17,6 @@ const Routes = () => (
<Route path="/offline" component={OfflineRoutes} />
<Route path="/categories/:id" component={CategoryRoutes} />
<Route path="/settings" component={SettingsPage} />
<Route path="/about" component={AboutPage} />
<Route path="/graphiql" component={GraphiQLPage} />
<Route component={() => <ErrorPage title="Not Found">Page not found</ErrorPage>} />
</Switch>
Expand Down
5 changes: 2 additions & 3 deletions ui/src/settings/SettingsPage.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React from 'react'
import { Redirect, Route, RouteComponentProps, Switch } from 'react-router'

import ButtonIcon from '../components/ButtonIcon'
import Appbar from '../layout/Appbar'
import Page from '../layout/Page'
import AddApiKeyForm from './api-keys/AddApiKeyForm'
Expand All @@ -16,7 +15,7 @@ import EditCategoryTab from './categories/EditCategoryTab'
import Header from './components/Header'
import Tabs from './components/Tabs'
import PreferencesTab from './preferences/PreferencesTab'
import { Link } from 'react-router-dom'
import AboutButton from './about/AboutButton'

const items = [
{ key: 'categories', label: 'Categories', icon: 'bookmarks' },
Expand All @@ -38,7 +37,7 @@ const PageHeader = () => (
<Appbar actions={<Actions />} />
<Header>
<h1>Settings</h1>
<ButtonIcon icon="info" as={Link} to="/about" title="About" />
<AboutButton />
<Tabs items={items} />
</Header>
</>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
.about > div {
display: block;
.about {
align-items: center;
padding: 0em 1em 2em 1em;
}

.about > button {
align-self: flex-end;
}

.about p {
color: var(--panel-text-color-alt)
}

.about h1 {
margin: 0;
padding: 0;
font-size: 2em;
font-weight: 500;
}

.about ul {
Expand All @@ -24,7 +31,6 @@
font-size: 1rem;
}


.about ul > li:first-child::before {
display: none;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react'
import ReactDOM from 'react-dom'

import AboutPage from './AboutPage'
import AboutButton from './AboutButton'

it('renders without crashing', () => {
const div = document.createElement('div')
ReactDOM.render(<AboutPage />, div)
ReactDOM.render(<AboutButton />, div)
ReactDOM.unmountComponentAtNode(div)
})
63 changes: 63 additions & 0 deletions ui/src/settings/about/AboutButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import React from 'react'
import ReactModal from 'react-modal'
import { useModal } from 'react-modal-hook'

import ButtonIcon from '../../components/ButtonIcon'
import Panel from '../../components/Panel'

import dialogStyles from '../../components/Dialog.module.css'
import styles from './AboutButton.module.css'
import logo from './logo.svg'
import { VERSION } from '../../constants'

interface Props {
closeHandler: () => void
}

const AboutPanel = ({ closeHandler }: Props) => (
<Panel className={styles.about}>
<ButtonIcon title="close" onClick={closeHandler} icon="close" />
<h1>
<img src={logo} />
</h1>
<span>({VERSION})</span>
<p>Read your Internet article flow in one place with complete peace of mind and freedom.</p>
<ul>
<li>
<a href="https://github.com/ncarlier/readflow" rel="noreferrer noopener" target="_blank">
Sources
</a>
</li>
<li>
<a href="https://github.com/ncarlier/readflow/issues" rel="noreferrer noopener" target="_blank">
Bug or feature request
</a>
</li>
<li>
<a href="https://www.paypal.me/nunux" rel="noreferrer noopener" target="_blank">
Support this project
</a>
</li>
</ul>
</Panel>
)

export default () => {
const [showAboutModal, hideAboutModal] = useModal(() => (
<ReactModal
isOpen
shouldCloseOnEsc
shouldCloseOnOverlayClick
shouldFocusAfterRender
appElement={document.getElementById('root')!}
onRequestClose={hideAboutModal}
className={dialogStyles.dialog}
overlayClassName={dialogStyles.overlay}
>
<AboutPanel closeHandler={hideAboutModal} />
</ReactModal>
))

return <ButtonIcon title="About" onClick={showAboutModal} icon="info" />
}
File renamed without changes

0 comments on commit 003d31c

Please sign in to comment.