Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): Add resources page to more section #1631

Merged
merged 3 commits into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/src/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import NavBar from './nav-bar'

import SidePanel from '../pages/SidePanel'
import Robots from '../pages/Robots'
import AppSettingsPage from '../pages/AppSettings'
import More from '../pages/More'
import Upload from '../pages/Upload'
import Calibrate from '../pages/Calibrate'
import Run from '../pages/Run'
Expand All @@ -22,7 +22,7 @@ export default function App () {
<Redirect from='(.*)/index.html' to='/' />
<Redirect exact from='/' to='/robots' />
<Route path='/robots/:name?' component={Robots} />
<Route path='/menu/app' component={AppSettingsPage} />
<Route path='/menu' component={More} />
<Route path='/upload' component={Upload} />
<Route path='/calibrate' component={Calibrate} />
<Route path='/run' component={Run} />
Expand Down
6 changes: 5 additions & 1 deletion app/src/components/MenuPanel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ export default function MenuPanel () {
return (
<SidePanel title='Menu'>
<div className={styles.menu_panel}>
<ol>
<ol className={styles.menu_list}>
<ListItem className={styles.menu_item} url={'/menu/app'} activeClassName={styles.active}>
<span>App</span>
<Icon name={'chevron-right'} className={styles.menu_icon}/>
</ListItem>
<ListItem className={styles.menu_item} url={'/menu/resources'} activeClassName={styles.active}>
<span>Resources</span>
<Icon name={'chevron-right'} className={styles.menu_icon}/>
</ListItem>
</ol>
</div>
</SidePanel>
Expand Down
5 changes: 3 additions & 2 deletions app/src/components/MenuPanel/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@

.menu_list {
list-style: none;
margin-left: 0;
margin: 1rem 0 0;
}

.menu_item {
margin-bottom: 0.5rem;
text-transform: uppercase;
font-size: var(--fs-body-2);
margin-bottom: 0.25rem;
box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.1);

& > span {
width: 100%;
Expand Down
23 changes: 23 additions & 0 deletions app/src/components/Resources/KnowledgeCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
// resources page layout
import * as React from 'react'
import {Card, OutlineButton} from '@opentrons/components'

const TITLE = 'Knowledge Base'

export default function KnowledgeCard () {
return (
<Card
title={TITLE}
>
<p>Visit our walkthroughs and FAQs</p>
<OutlineButton
Component="a"
href="https://support.opentrons.com"
target="_blank"
>
View in Browser
</OutlineButton>
</Card>
)
}
23 changes: 23 additions & 0 deletions app/src/components/Resources/LibraryCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @flow
// resources page layout
import * as React from 'react'
import {Card, OutlineButton} from '@opentrons/components'

const TITLE = 'Protocol Library'

export default function LibraryCard () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need separate components for KnowledgeCard and LibraryCard? Seems like we could get away with a ExternalResourceCard that takes children or a message prop and an external link

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough. Will change with https comment below

return (
<Card
title={TITLE}
>
<p>Download a protocol to run on your robot</p>
<OutlineButton
Component="a"
href="http://protocols.opentrons.com/"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's do https by default

target="_blank"
>
View in Browser
</OutlineButton>
</Card>
)
}
21 changes: 21 additions & 0 deletions app/src/components/Resources/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// @flow
// resources page layout
import * as React from 'react'

import KnowledgeCard from './KnowledgeCard'
import LibraryCard from './LibraryCard'

import styles from './styles.css'

export default function Resources () {
return (
<div className={styles.resources_page}>
<div className={styles.row}>
<KnowledgeCard />
</div>
<div className={styles.row}>
<LibraryCard />
</div>
</div>
)
}
16 changes: 16 additions & 0 deletions app/src/components/Resources/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/* stylesheet for Resources page components */
@import '@opentrons/components';

:root {
--resources_card_spacing: 0.75rem;
}

.resources_page {
padding: 1.5rem;
font-size: var(--fs-body-1);
}

.row {
width: 100%;
margin-bottom: var(--resources_card_spacing);
}
2 changes: 1 addition & 1 deletion app/src/components/nav-bar/NavButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ function mapStateToProps (state: State, ownProps: OwnProps): StateProps {
iconName: 'dots-horizontal',
isBottom: true,
title: 'more',
url: '/menu/app',
url: '/menu',
notification: moreNotification
}
}
Expand Down
76 changes: 76 additions & 0 deletions app/src/pages/More/AppSettings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// @flow
// view info about the app and update
import React from 'react'
import {connect} from 'react-redux'
import {Route, Switch, Redirect, type ContextRouter} from 'react-router'
import {push} from 'react-router-redux'

import type {State} from '../../types'
import type {ShellUpdate} from '../../shell'
import {
getShellUpdate,
checkForShellUpdates,
downloadShellUpdate,
quitAndInstallShellUpdate,
setUpdateSeen
} from '../../shell'

import Page from '../../components/Page'
import AppSettings, {AppUpdateModal} from '../../components/AppSettings'

type OP = ContextRouter

type SP = {
update: ShellUpdate,
}

type DP = {
checkForUpdates: () => mixed,
downloadUpdate: () => mixed,
quitAndInstall: () => mixed,
closeUpdateModal: () => mixed,
}

type Props = OP & SP & DP

export default connect(mapStateToProps, mapDispatchToProps)(AppSettingsPage)

function AppSettingsPage (props: Props) {
const {update, match: {path}} = props

return (
<Page>
<AppSettings {...props} />
<Switch>
<Route path={`${path}/update`} render={() => (
<AppUpdateModal {...props} close={props.closeUpdateModal} />
)} />
<Route render={() => {
if (update.available && !update.seen) {
return (<Redirect to='/menu/app/update' />)
}

return null
}} />
</Switch>
</Page>
)
}

function mapStateToProps (state: State): SP {
return {
update: getShellUpdate(state)
}
}

function mapDispatchToProps (dispatch: Dispatch): DP {
return {
checkForUpdates: () => dispatch(checkForShellUpdates()),
downloadUpdate: () => dispatch(downloadShellUpdate()),
quitAndInstall: () => quitAndInstallShellUpdate(),
closeUpdateModal: () => {
dispatch(setUpdateSeen())
dispatch(push('/menu/app'))
}
}
}
10 changes: 10 additions & 0 deletions app/src/pages/More/Resources.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react'
import Page from '../../components/Page'
import Resources from '../../components/Resources'
export default function ResourcesPage () {
return (
<Page>
<Resources />
</Page>
)
}
28 changes: 28 additions & 0 deletions app/src/pages/More/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// @flow
// more nav button routes
import * as React from 'react'
import {Switch, Route, Redirect, type Match} from 'react-router'

import AppSettings from './AppSettings'
import Resources from './Resources'

type Props = {
match: Match
}

export default function More (props: Props) {
const {match: {path}} = props
return (
<Switch>
<Redirect exact from={path} to={'/menu/app'} />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to prop should use path to build the route so we can change the top level path (/menu) in only one place

<Redirect exact from={path} to={`${path}/app`} />

<Route
path={'/menu/app'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also use path to build route

path={`${path}/app`}

Given the redirect above, it might be worth doing...

const appPath = `${path}/app`

...up top for the Redirect's to and the Route's path

component={AppSettings}
/>
<Route
path={'/menu/resources'}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should also use path to build route

path={`${path}/resources`}

component={Resources}
/>
</Switch>
)
}