···11-/* eslint-disable react/no-multi-comp */
22-import React, { Component } from 'react';
33-import { Segment, Header, Menu, Icon, Button, Grid } from 'semantic-ui-react';
44-import styles from '../styles/common.css';
55-66-const HELP_STEP = {
77- MENU: 0,
88- SIGNAL_EXPLANATION: 1,
99- SIGNAL_SALINE: 2,
1010- SIGNAL_CONTACT: 3,
1111- SIGNAL_MOVEMENT: 4,
1212- LEARN_BRAIN: 5,
1313- LEARN_BLINK: 6,
1414- LEARN_THOUGHTS: 7,
1515- LEARN_ALPHA: 8,
1616-};
1717-1818-interface Props {
1919- handleClose: () => void;
2020-}
2121-2222-interface State {
2323- helpStep: HELP_STEP;
2424-}
2525-2626-// TODO: Refactor this into a more reusable Sidebar component that can be used in Collect, Clean, and Analyze screen
2727-export class HelpSidebar extends Component<Props, State> {
2828- // props: Props;
2929-3030- constructor(props) {
3131- super(props);
3232- this.state = {
3333- helpStep: HELP_STEP.MENU,
3434- };
3535- this.handleStartLearn = this.handleStartLearn.bind(this);
3636- this.handleStartSignal = this.handleStartSignal.bind(this);
3737- this.handleNext = this.handleNext.bind(this);
3838- this.handleBack = this.handleBack.bind(this);
3939- }
4040-4141- handleStartSignal() {
4242- this.setState({ helpStep: HELP_STEP.SIGNAL_EXPLANATION });
4343- }
4444-4545- handleStartLearn() {
4646- this.setState({ helpStep: HELP_STEP.LEARN_BRAIN });
4747- }
4848-4949- handleNext() {
5050- if (
5151- this.state.helpStep === HELP_STEP.SIGNAL_MOVEMENT ||
5252- this.state.helpStep === HELP_STEP.LEARN_ALPHA
5353- ) {
5454- this.setState({ helpStep: HELP_STEP.MENU });
5555- } else {
5656- this.setState((prevState) => ({ ...prevState, helpStep: prevState.helpStep + 1 }));
5757- }
5858- }
5959-6060- handleBack() {
6161- this.setState((prevState) => ({ ...prevState, helpStep: prevState.helpStep - 1 }));
6262- }
6363-6464- renderMenu() {
6565- return (
6666- <>
6767- <Menu secondary vertical fluid>
6868- <Header className={styles.helpHeader} as='h1'>
6969- What would you like to do?
7070- </Header>
7171- <Menu.Item onClick={this.handleStartSignal}>
7272- <Segment basic className={styles.helpMenuItem}>
7373- <Icon name='star outline' size='large' />
7474- Improve the signal quality of your sensors
7575- </Segment>
7676- </Menu.Item>
7777- <Menu.Item onClick={this.handleStartLearn}>
7878- <Segment basic className={styles.helpMenuItem}>
7979- <Icon name='exclamation triangle' size='large' />
8080- Learn about how the subjects movements create noise
8181- </Segment>
8282- </Menu.Item>
8383- </Menu>
8484- </>
8585- );
8686- }
8787-8888- renderHelp(header: string, content: string) {
8989- return (
9090- <>
9191- <Segment basic className={styles.helpContent}>
9292- <Header className={styles.helpHeader} as='h1'>
9393- {header}
9494- </Header>
9595- {content}
9696- </Segment>
9797- <Grid columns='equal'>
9898- <Grid.Column>
9999- <Button fluid secondary onClick={this.handleBack}>
100100- Back
101101- </Button>
102102- </Grid.Column>
103103- <Grid.Column>
104104- <Button fluid primary onClick={this.handleNext}>
105105- Next
106106- </Button>
107107- </Grid.Column>
108108- </Grid>
109109- </>
110110- );
111111- }
112112-113113- renderHelpContent() {
114114- switch (this.state.helpStep) {
115115- case HELP_STEP.SIGNAL_EXPLANATION:
116116- return this.renderHelp(
117117- 'Improve the signal quality',
118118- 'In order to collect quality data, you want to make sure that all electrodes have a strong connection'
119119- );
120120- case HELP_STEP.SIGNAL_SALINE:
121121- return this.renderHelp(
122122- 'Tip #1: Saturate the sensors in saline',
123123- 'Make sure the sensors are thoroughly soaked with saline solution. They should be wet to the touch'
124124- );
125125- case HELP_STEP.SIGNAL_CONTACT:
126126- return this.renderHelp(
127127- 'Tip #2: Ensure the sensors are making firm contact',
128128- 'Re-seat the headset to make sure that all sensors contact the head with some tension. Take extra care to make sure the reference electrodes (the ones right behind the ears) make proper contact. You may need to sweep hair out of the way to accomplish this'
129129- );
130130- case HELP_STEP.SIGNAL_MOVEMENT:
131131- return this.renderHelp(
132132- 'Tip #3: Stay still',
133133- 'To reduce noise during your experiment, ensure your subject is relaxed and has both feet on the floor. Sometimes, focusing on relaxing the jaw and the tongue can improve the EEG signal'
134134- );
135135- case HELP_STEP.LEARN_BRAIN:
136136- return this.renderHelp(
137137- 'Your brain produces electricity',
138138- 'Using the device that you are wearing, we can detect the electrical activity of your brain.'
139139- );
140140- case HELP_STEP.LEARN_BLINK:
141141- return this.renderHelp(
142142- 'Try blinking your eyes',
143143- 'Does the signal change? Eye movements create noise in the EEG signal'
144144- );
145145- case HELP_STEP.LEARN_THOUGHTS:
146146- return this.renderHelp(
147147- 'Try thinking of a cat',
148148- "Does the signal change? Although EEG can measure overall brain activity, it's not capable of reading minds"
149149- );
150150- case HELP_STEP.LEARN_ALPHA:
151151- return this.renderHelp(
152152- 'Try closing your eyes for 10 seconds',
153153- 'You may notice a change in your signal due to an increase in alpha waves'
154154- );
155155- case HELP_STEP.MENU:
156156- default:
157157- return this.renderMenu();
158158- }
159159- }
160160-161161- render() {
162162- return (
163163- <Segment basic padded vertical className={styles.helpSidebar}>
164164- <Segment basic className={styles.closeButton}>
165165- <Button circular size='large' icon='x' onClick={this.props.handleClose} />
166166- </Segment>
167167- {this.renderHelpContent()}
168168- </Segment>
169169- );
170170- }
171171-}
172172-173173-export class HelpButton extends Component<{ onClick: () => void }, {}> {
174174- render() {
175175- return (
176176- <Button
177177- circular
178178- icon='question'
179179- className={styles.helpButton}
180180- floated='right'
181181- onClick={this.props.onClick}
182182- />
183183- );
184184- }
185185-}
+145
app/components/CollectComponent/HelpSidebar.tsx
···11+/* eslint-disable react/no-multi-comp */
22+import React, { Component } from "react";
33+import { Segment, Header, Menu, Icon, Button, Grid } from "semantic-ui-react";
44+import styles from "../styles/common.css";
55+66+const HELP_STEP = {
77+ MENU: 0,
88+ SIGNAL_EXPLANATION: 1,
99+ SIGNAL_SALINE: 2,
1010+ SIGNAL_CONTACT: 3,
1111+ SIGNAL_MOVEMENT: 4,
1212+ LEARN_BRAIN: 5,
1313+ LEARN_BLINK: 6,
1414+ LEARN_THOUGHTS: 7,
1515+ LEARN_ALPHA: 8
1616+};
1717+1818+interface Props {
1919+ handleClose: () => void;
2020+}
2121+2222+interface State {
2323+ helpStep: HELP_STEP;
2424+}
2525+2626+// TODO: Refactor this into a more reusable Sidebar component that can be used in Collect, Clean, and Analyze screen
2727+export class HelpSidebar extends Component<Props, State> {
2828+ // props: Props;
2929+3030+ constructor(props) {
3131+ super(props);
3232+ this.state = {
3333+ helpStep: HELP_STEP.MENU
3434+ };
3535+ this.handleStartLearn = this.handleStartLearn.bind(this);
3636+ this.handleStartSignal = this.handleStartSignal.bind(this);
3737+ this.handleNext = this.handleNext.bind(this);
3838+ this.handleBack = this.handleBack.bind(this);
3939+ }
4040+4141+ handleStartSignal() {
4242+ this.setState({ helpStep: HELP_STEP.SIGNAL_EXPLANATION });
4343+ }
4444+4545+ handleStartLearn() {
4646+ this.setState({ helpStep: HELP_STEP.LEARN_BRAIN });
4747+ }
4848+4949+ handleNext() {
5050+ if (this.state.helpStep === HELP_STEP.SIGNAL_MOVEMENT || this.state.helpStep === HELP_STEP.LEARN_ALPHA) {
5151+ this.setState({ helpStep: HELP_STEP.MENU });
5252+ } else {
5353+ this.setState(prevState => ({ ...prevState, helpStep: prevState.helpStep + 1 }));
5454+ }
5555+ }
5656+5757+ handleBack() {
5858+ this.setState(prevState => ({ ...prevState, helpStep: prevState.helpStep - 1 }));
5959+ }
6060+6161+ renderMenu() {
6262+ return <>
6363+ <Menu secondary vertical fluid>
6464+ <Header className={styles.helpHeader} as='h1'>
6565+ What would you like to do?
6666+ </Header>
6767+ <Menu.Item onClick={this.handleStartSignal}>
6868+ <Segment basic className={styles.helpMenuItem}>
6969+ <Icon name='star outline' size='large' />
7070+ Improve the signal quality of your sensors
7171+ </Segment>
7272+ </Menu.Item>
7373+ <Menu.Item onClick={this.handleStartLearn}>
7474+ <Segment basic className={styles.helpMenuItem}>
7575+ <Icon name='exclamation triangle' size='large' />
7676+ Learn about how the subjects movements create noise
7777+ </Segment>
7878+ </Menu.Item>
7979+ </Menu>
8080+ </>;
8181+ }
8282+8383+ renderHelp(header: string, content: string) {
8484+ return <>
8585+ <Segment basic className={styles.helpContent}>
8686+ <Header className={styles.helpHeader} as='h1'>
8787+ {header}
8888+ </Header>
8989+ {content}
9090+ </Segment>
9191+ <Grid columns='equal'>
9292+ <Grid.Column>
9393+ <Button fluid secondary onClick={this.handleBack}>
9494+ Back
9595+ </Button>
9696+ </Grid.Column>
9797+ <Grid.Column>
9898+ <Button fluid primary onClick={this.handleNext}>
9999+ Next
100100+ </Button>
101101+ </Grid.Column>
102102+ </Grid>
103103+ </>;
104104+ }
105105+106106+ renderHelpContent() {
107107+ switch (this.state.helpStep) {
108108+ case HELP_STEP.SIGNAL_EXPLANATION:
109109+ return this.renderHelp('Improve the signal quality', 'In order to collect quality data, you want to make sure that all electrodes have a strong connection');
110110+ case HELP_STEP.SIGNAL_SALINE:
111111+ return this.renderHelp('Tip #1: Saturate the sensors in saline', 'Make sure the sensors are thoroughly soaked with saline solution. They should be wet to the touch');
112112+ case HELP_STEP.SIGNAL_CONTACT:
113113+ return this.renderHelp('Tip #2: Ensure the sensors are making firm contact', 'Re-seat the headset to make sure that all sensors contact the head with some tension. Take extra care to make sure the reference electrodes (the ones right behind the ears) make proper contact. You may need to sweep hair out of the way to accomplish this');
114114+ case HELP_STEP.SIGNAL_MOVEMENT:
115115+ return this.renderHelp('Tip #3: Stay still', 'To reduce noise during your experiment, ensure your subject is relaxed and has both feet on the floor. Sometimes, focusing on relaxing the jaw and the tongue can improve the EEG signal');
116116+ case HELP_STEP.LEARN_BRAIN:
117117+ return this.renderHelp('Your brain produces electricity', 'Using the device that you are wearing, we can detect the electrical activity of your brain.');
118118+ case HELP_STEP.LEARN_BLINK:
119119+ return this.renderHelp('Try blinking your eyes', 'Does the signal change? Eye movements create noise in the EEG signal');
120120+ case HELP_STEP.LEARN_THOUGHTS:
121121+ return this.renderHelp('Try thinking of a cat', "Does the signal change? Although EEG can measure overall brain activity, it's not capable of reading minds");
122122+ case HELP_STEP.LEARN_ALPHA:
123123+ return this.renderHelp('Try closing your eyes for 10 seconds', 'You may notice a change in your signal due to an increase in alpha waves');
124124+ case HELP_STEP.MENU:default:
125125+ return this.renderMenu();
126126+127127+ }
128128+ }
129129+130130+ render() {
131131+ return <Segment basic padded vertical className={styles.helpSidebar}>
132132+ <Segment basic className={styles.closeButton}>
133133+ <Button circular size='large' icon='x' onClick={this.props.handleClose} />
134134+ </Segment>
135135+ {this.renderHelpContent()}
136136+ </Segment>;
137137+ }
138138+}
139139+140140+export class HelpButton extends Component<{onClick: () => void;}, {}> {
141141+142142+ render() {
143143+ return <Button circular icon='question' className={styles.helpButton} floated='right' onClick={this.props.onClick} />;
144144+ }
145145+}