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

Howto guide #57

Merged
merged 34 commits into from
Nov 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d9e7108
Commit pas rapport
abelfodil Oct 31, 2020
116439d
First pass adding content
abelfodil Oct 31, 2020
b7f704a
Beautify the page
abelfodil Nov 4, 2020
8f9b08d
Remove separator
abelfodil Nov 4, 2020
c08fd2a
Shorten code
abelfodil Nov 4, 2020
8073e7e
Add illustrations
abelfodil Nov 6, 2020
e6d17d2
Add material icons
abelfodil Nov 6, 2020
7261f81
Move electrodes to tabs
abelfodil Nov 6, 2020
3d7ea6e
Alternate text and images
abelfodil Nov 6, 2020
9b64e26
Make text bigger
abelfodil Nov 6, 2020
7c16162
Add user friendly electrode placement
abelfodil Nov 6, 2020
38545af
change tab police size
abelfodil Nov 6, 2020
9ee2339
Change column size
abelfodil Nov 6, 2020
15b8e66
cleaner code
abelfodil Nov 6, 2020
b8a3ab0
Use cards
abelfodil Nov 6, 2020
c395d2d
Fix space
abelfodil Nov 6, 2020
23e242e
cleanup
abelfodil Nov 6, 2020
a4ff21f
Update web/src/views/record_my_sleep/index.js
abelfodil Nov 7, 2020
a61ee2d
Add intro to list
abelfodil Nov 7, 2020
aceace0
Remove space between title and first section
abelfodil Nov 7, 2020
baabff9
Add space between elements
abelfodil Nov 7, 2020
7e2a328
Fix tabs
abelfodil Nov 7, 2020
dd222b1
Reomve hovering effect
abelfodil Nov 7, 2020
12b5a55
Title
abelfodil Nov 7, 2020
903cab0
Add images
abelfodil Nov 7, 2020
ac533e9
Fix
abelfodil Nov 7, 2020
aaa925f
Add hovering cards
abelfodil Nov 7, 2020
34d62f9
Update web/src/views/record_my_sleep/index.js
abelfodil Nov 7, 2020
96de1c8
Update web/src/views/record_my_sleep/index.js
abelfodil Nov 7, 2020
f57e735
Update web/src/views/record_my_sleep/index.js
abelfodil Nov 7, 2020
87f9e15
Reuse section
abelfodil Nov 7, 2020
ede0924
Remove redundant statement
abelfodil Nov 7, 2020
324b140
Add badges
abelfodil Nov 7, 2020
21988f3
Add carousel
abelfodil Nov 7, 2020
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
2 changes: 2 additions & 0 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
"not op_mini all"
],
"dependencies": {
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@octokit/rest": "^18.0.6",
"axios": "^0.19.0",
"axios-observable": "^1.1.3",
Expand Down
Binary file added web/public/illustrations/chip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/ec2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/electrode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/electrodes_ten20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/gauze_ec2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/gauze_electrodes.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/gauze_pads.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/hypafix.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/measuring_tape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/medical_tape.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/prep_gel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/sd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/ten20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/illustrations/top.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/instructions/res_1.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/instructions/res_2.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/instructions/res_3.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/instructions/res_4.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/instructions/res_5.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/instructions/res_6.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions web/src/components/alternating_text_image.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import React from 'react';
import { Row, Col } from 'reactstrap';

const AlternatingTextImage = ({ elements }) =>
elements.map(({ title, text, image }, i) => {
const textElement = (
<>
<h4 className="display-4">{title}</h4>
<p className="lead">{text}</p>
</>
);

const imageElement = <img src={`${process.env.PUBLIC_URL}/${image}`} alt={title} />;

return (
<div className="pt-lg-5" key={i}>
{i % 2 === 0 ? (
<Row>
<Col xs="8">{textElement}</Col>
<Col xs="4">{imageElement}</Col>
</Row>
) : (
<Row>
<Col xs="4">{imageElement}</Col>
<Col xs="8">{textElement}</Col>
</Row>
)}
</div>
);
});
export default AlternatingTextImage;
44 changes: 44 additions & 0 deletions web/src/components/carousel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useState } from 'react';
import { Carousel, CarouselItem, CarouselControl, CarouselIndicators, CarouselCaption } from 'reactstrap';

const SimpleCarousel = ({ items }) => {
const [activeIndex, setActiveIndex] = useState(0);
const [animating, setAnimating] = useState(false);

const next = () => {
if (animating) return;
const nextIndex = activeIndex === items.length - 1 ? 0 : activeIndex + 1;
setActiveIndex(nextIndex);
};

const previous = () => {
if (animating) return;
const nextIndex = activeIndex === 0 ? items.length - 1 : activeIndex - 1;
setActiveIndex(nextIndex);
};

const goToIndex = (newIndex) => {
if (animating) return;
setActiveIndex(newIndex);
};

const slides = items.map((item) => {
return (
<CarouselItem onExiting={() => setAnimating(true)} onExited={() => setAnimating(false)} key={item.src}>
<img src={`${process.env.PUBLIC_URL}/${item.src}`} alt={item.altText} width="100%" />
<CarouselCaption captionText="" captionHeader={item.caption} />
</CarouselItem>
);
});

return (
<Carousel activeIndex={activeIndex} next={next} previous={previous}>
<CarouselIndicators items={items} activeIndex={activeIndex} onClickHandler={goToIndex} />
{slides}
<CarouselControl direction="prev" directionText="Previous" onClickHandler={previous} />
<CarouselControl direction="next" directionText="Next" onClickHandler={next} />
</Carousel>
);
};

export default SimpleCarousel;
25 changes: 25 additions & 0 deletions web/src/components/table.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { Table } from 'reactstrap';

const SimpleTable = ({ headers, elementsRows }) => (
<Table striped borderless responsive>
<thead>
<tr>
{headers.map((header) => (
<th key={header}>{header}</th>
))}
</tr>
</thead>
<tbody>
{elementsRows.map((row, i) => (
<tr key={i}>
{row.map((element) => (
<td key={element}>{element}</td>
))}
</tr>
))}
</tbody>
</Table>
);

export default SimpleTable;
53 changes: 53 additions & 0 deletions web/src/components/tabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React, { useState } from 'react';
import classnames from 'classnames';
import { Card, CardBody, NavItem, NavLink, Nav, TabContent, TabPane } from 'reactstrap';

const Tabs = ({ elements, onSelectTab, onHoverTab }) => {
const [selectedTab, _setSelectedTab] = useState(0);
const setSelectedTab = (event, tab) => {
event.preventDefault();
_setSelectedTab(tab);
};

return (
<>
<div className="nav-wrapper">
<Nav className="nav-fill flex-column flex-md-row" id="tabs-icons-text" pills role="tablist">
{elements.map(({ id, title }, i) => (
<NavItem key={i}>
<NavLink
aria-selected={selectedTab === i}
className={classnames('mb-sm-3 mb-md-0', {
active: selectedTab === i,
})}
onClick={(e) => {
onSelectTab && onSelectTab(id);
setSelectedTab(e, i);
}}
onMouseOver={() => onHoverTab && onHoverTab(id)}
onMouseLeave={() => onHoverTab && onHoverTab(null)}
href="#pablo"
role="tab"
>
{title}
</NavLink>
</NavItem>
))}
</Nav>
</div>
<Card className="shadow">
<CardBody>
<TabContent activeTab={'selectedTab' + selectedTab}>
{elements.map(({ content }, i) => (
<TabPane key={i} tabId={'selectedTab' + i}>
<p>{content}</p>
</TabPane>
))}
</TabContent>
</CardBody>
</Card>
</>
);
};

export default Tabs;
3 changes: 2 additions & 1 deletion web/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Navbar from 'components/navbar';
import SleepAnalysisResults from 'views/sleep_analysis_results';
import Performance from 'views/performance';
import AnalyzeSleep from 'views/analyze_sleep';
import RecordMySleep from 'views/record_my_sleep';
import ScrollToTop from 'components/scroll_to_top';
import Emoji from 'components/emoji';

Expand Down Expand Up @@ -46,7 +47,7 @@ ReactDOM.render(
<Navbar />
<Switch>
<Route exact path="/" render={underConstruction} />
<Route exact path="/record-my-sleep" render={underConstruction} />
<Route exact path="/record-my-sleep" render={() => <RecordMySleep />} />
<Route exact path="/analyze-my-sleep" render={() => <AnalyzeSleep />} />
<Route exact path="/sleep-analysis-results" render={() => <SleepAnalysisResults />} />
<Route exact path="/performance" render={() => <Performance />} />
Expand Down
2 changes: 1 addition & 1 deletion web/src/views/analyze_sleep/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { periodicPingServer } from 'requests/ping_server';
import WaitingForServer from './waiting_for_server';
import UploadForm from './upload_form';
import { PING_PERIOD } from './constants';
import AnalysisInProgress from './analysis_in_progress.js';
import AnalysisInProgress from './analysis_in_progress';

import text from './text.json';

Expand Down
34 changes: 34 additions & 0 deletions web/src/views/record_my_sleep/carousel_images.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"items": [
{
"src": "instructions/res_1.jpg",
"altText": "Slide 1",
"caption": "1"
},
{
"src": "instructions/res_2.jpg",
"altText": "Slide 2",
"caption": "2"
},
{
"src": "instructions/res_3.jpg",
"altText": "Slide 3",
"caption": "3"
},
{
"src": "instructions/res_4.jpg",
"altText": "Slide 4",
"caption": "4"
},
{
"src": "instructions/res_5.jpg",
"altText": "Slide 5",
"caption": "5"
},
{
"src": "instructions/res_6.jpg",
"altText": "Slide 6",
"caption": "6"
}
]
}
78 changes: 78 additions & 0 deletions web/src/views/record_my_sleep/electrode_display.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
.imgs-container {
position: relative;
text-align: center;
}

.img-container {
position: relative;
text-align: center;
min-width: 50px;
min-height: 50px;
display: inline-block;
}

.dot {
height: 10px;
width: 10px;
border-radius: 50%;
display: inline-block;
position: absolute;
}

.dot-select {
background-color: #fc7c5f;
}

.dot-null {
display: none;
}

.top.dot-fpz {
top: 3%;
left: 47%;
}

.top.dot-cz {
top: 46%;
left: 47%;
}

.top.dot-pz {
top: 76%;
left: 46%;
}

.top.dot-oz {
top: 89%;
left: 46%;
}

.top.dot-a2 {
top: 48%;
left: 90%;
}

.side.dot-fpz {
top: 38%;
left: 70%;
}

.side.dot-cz {
top: 17%;
left: 43%;
}

.side.dot-pz {
top: 28%;
left: 27%;
}

.side.dot-oz {
top: 51%;
left: 23%;
}

.side.dot-a2 {
top: 58%;
left: 49%;
}
73 changes: 73 additions & 0 deletions web/src/views/record_my_sleep/electrodes_display.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import React, { useState } from 'react';
import { Row, Col } from 'reactstrap';

import Tabs from 'components/tabs';

import './electrode_display.css';

const ElectrodesDisplay = () => {
const [selectedElectrode, setSelectedElectrode] = useState('fpz');

return (
<Row>
<Col xs="8">
<Tabs
onSelectTab={setSelectedElectrode}
elements={[
{
id: 'fpz',
title: 'Fpz',
content: `
Fpz is used as one of our active electrodes. To identify the Fpz location, just measure the distance
starting from your nasion (the easily identifiable depressed area between your eyes) to your inion
using your flexible measuring tape. Fpz is located at 10 % of the distance along the midline between
your nasion and your inion.`,
},
{
id: 'cz',
title: 'Cz',
content: `
We’re measuring a potential difference between Fpz and that point. Cz is located at 50% of the
distance along the midline starting from your nasion to your inion.`,
},
{
id: 'pz',
title: 'Pz',
content: `
This is our other active electrode. It is located at 70% of the distance between your nasion and your
inion.`,
},
{
id: 'oz',
title: 'Oz',
content: `
This is the point at which Pz is referenced. It is located at 90% of the distance between your nasion
and your inion.`,
},
{
id: 'a2',
title: 'A2',
content: `
This is the electrode that serves as driven ground between your and your OpenBCI board. Simply place it on
your right earlobe.`,
},
]}
/>
</Col>
<Col xs="4">
<div className="imgs-container">
<div className="img-container">
<img src={`${process.env.PUBLIC_URL}/illustrations/top.png`} alt="top" />
conorato marked this conversation as resolved.
Show resolved Hide resolved
<span className={`top dot dot-select dot-${selectedElectrode}`}></span>
</div>
<div className="img-container">
<img src={`${process.env.PUBLIC_URL}/illustrations/side.png`} alt="side" />
<span className={`side dot dot-select dot-${selectedElectrode}`}></span>
</div>
</div>
</Col>
</Row>
);
};

export default ElectrodesDisplay;
Loading