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

Fix tour #1049

Merged
merged 14 commits into from
Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions neuroscout/frontend/cypress/integration/tour.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('Tour', () => {
it('opens tour', () => {
cy.visit('/')
cy.login('user@example.com', 'string')
cy.wait(200)
cy.get('#rainbow-btn').click()
})
})
5 changes: 4 additions & 1 deletion neuroscout/frontend/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,10 @@ class App extends React.Component<Record<string, never>, AppState> {
<ResetPasswordModal {...this.state.user} />
)}
{this.state.user.openSignup && <SignupModal {...this.state.user} />}
{Tour(this.state.user.openTour, this.state.user.closeTour)}
<Tour
isOpen={this.state.user.openTour}
closeTour={this.state.user.closeTour}
/>
<Layout>
<Content style={{ background: '#fff' }}>
<Navbar {...this.state.user} />
Expand Down
13 changes: 13 additions & 0 deletions neuroscout/frontend/src/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
*/
import * as React from 'react'
import { Divider, Row, Col, Button, Card } from 'antd'
import { CoffeeOutlined } from '@ant-design/icons'
import { MainCol } from './HelperComponents'
import { UserStore } from './user'
import { BookOutlined } from '@ant-design/icons'
Expand Down Expand Up @@ -68,6 +69,18 @@ class Home extends React.Component<UserStore, Record<string, never>> {
Sign up to get started!
</Button>
)}
{!this.props.loggedIn === false && (
<Button
size="large"
className="splashButton"
id="rainbow-btn"
type="primary"
onClick={e => this.props.update({ openTour: true })}
>
<CoffeeOutlined />
Take a Tour!
</Button>
)}
</div>
</div>
<Divider />
Expand Down
20 changes: 16 additions & 4 deletions neuroscout/frontend/src/Tour.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import * as React from 'react'
import Reactour from 'reactour'
import { withRouter } from 'react-router-dom'
import { RouteComponentProps } from 'react-router'

const Tour = (isOpen, closeTour) => {
return withRouter(({ location: { pathname }, history }) => {
type TourProps = RouteComponentProps & {
isOpen: boolean
closeTour: () => void
}

class Tour extends React.Component<TourProps, Record<string, never>> {
render() {
const { location, history, closeTour, isOpen } = this.props
const pathname = location.pathname
const steps = [
{
content:
Expand All @@ -22,6 +30,7 @@ const Tour = (isOpen, closeTour) => {
? [
{
action: () => history.push('/builder'),
content: '',
},
]
: pathname === '/builder'
Expand All @@ -44,6 +53,9 @@ const Tour = (isOpen, closeTour) => {
: []),
]

if (!isOpen) {
return null
}
return (
<Reactour
steps={steps}
Expand All @@ -52,7 +64,7 @@ const Tour = (isOpen, closeTour) => {
update={pathname}
/>
)
})
}
}

export default Tour
export default withRouter(Tour)
1 change: 1 addition & 0 deletions neuroscout/frontend/src/analysis_builder/Status.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type submitProps = {
private: boolean
updateAnalysis?: (value: Partial<Analysis>) => void
userOwns?: boolean
children?: React.ReactNode
}

export class Submit extends React.Component<
Expand Down
17 changes: 17 additions & 0 deletions neuroscout/frontend/src/css/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,20 @@ pre {
.colorIndexPredictorList {
margin-bottom: 20px;
}

@keyframes kfcolors {
0% {background:#69c0ff;}
40% {background:#1890ff;}
60% {background:#096dd9;}
100% {background:#0050b3;}
}

#rainbow-btn {
background:red;
animation: kfcolors ease;
animation-direction: alternate;
animation-duration: 4s;
animation-iteration-count: infinite;
}


Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type FilesAndRunsFormProps = {
runFilters: RunFilters
display: boolean
}[]
children?: React.ReactNode
}

function _empty(filters) {
Expand Down
2 changes: 1 addition & 1 deletion neuroscout/frontend/src/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ export class UserStore {
jwt: jwt,
password: '',
loggedIn: true,
openLogin: false,
nextURL: null,
openLogin: false,
loginError: '',
})
})
Expand Down