Skip to content

Commit

Permalink
Add links to EmotionResults and fix antipattern in Play
Browse files Browse the repository at this point in the history
  • Loading branch information
Leta Keane committed Jun 6, 2017
1 parent b1090f9 commit a59ca72
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 12 deletions.
20 changes: 20 additions & 0 deletions app/assets/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ button:focus {
outline: rgba(0, 0, 0, 0);
}

a:focus {
outline: rgba(0, 0, 0, 0);
}

.hidden {
display: none;
}
Expand Down Expand Up @@ -228,6 +232,22 @@ video {
margin: 0 0 20px 0;
}

.learn-more-link {
display: flex;
align-items: center;
justify-content: center;
height: 50px;
background-color: rgba(237, 205, 156, 1);
color: white;
border-radius: 50px;
margin-bottom: 30px;
}

.learn-more-link:hover {
font-weight: 700;
box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.2);
}



/*LEARN SECTION*/
Expand Down
16 changes: 13 additions & 3 deletions app/components/EmotionResults/EmotionResults.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
import React from 'react';
import { Link } from 'react-router-dom';
import analyzeResponse from '../../lib/analyzeResponse.js';

export const EmotionResults = ({ results, url }) => {
export const EmotionResults = ({ results, url, pickedEmotion }) => {
const noResults = () => {
return (
<h2 className='no-results'>Take a picture to see your expression!</h2>
)
}

const ifNotNeutralContemptRenderLink = (emotion) => {
if (emotion !== 'neutral' && emotion !== 'contempt') {
return (
<Link className='learn-more-link' to={`/learn/${emotion}`}>Learn more about {emotion}</Link>
)
}
}

const showResults = () => {
let emotionsForDisplay = analyzeResponse(results);
return (
Expand All @@ -16,7 +25,7 @@ export const EmotionResults = ({ results, url }) => {
<h2 className='results'>your expression is:</h2>
{
emotionsForDisplay.map((emotionObject, index) => {
if (emotionObject !== undefined) {
if (emotionObject !== undefined && emotionObject.emotion !== 'contempt') {
return (
<div key={emotionObject.emotion}>
<h3 key={index}
Expand All @@ -26,6 +35,7 @@ export const EmotionResults = ({ results, url }) => {
<h2 className='emotion-score'>
{emotionObject.emotion}
</h2>
{ifNotNeutralContemptRenderLink(emotionObject.emotion)}
</div>
)
}
Expand All @@ -36,7 +46,7 @@ export const EmotionResults = ({ results, url }) => {
}

const displayResults = () => {
return !results.length ? noResults() : showResults()
return (!results.length) ? noResults() : showResults()
}

return (
Expand Down
2 changes: 0 additions & 2 deletions app/components/Learn/LearnNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ export const LearnNav = () => {
return (
<nav>
<ul>

<li>
<NavLink
to="/learn/happiness"
Expand Down Expand Up @@ -59,7 +58,6 @@ export const LearnNav = () => {
about
</NavLink>
</li>

</ul>
</nav>
)
Expand Down
2 changes: 1 addition & 1 deletion app/components/Learn/emotions/Surprise.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const Surprise = () => {
<article>
<h2>What does surprise look like?</h2>
<ul>
<li>Eyes wide open, or sometimes squeezeed shut</li>
<li>Eyes wide open, or sometimes squeezed shut</li>
<li>Eyebrows raised</li>
<li>Mouth usually open, sometimes lips are pursed into a small 'O' shape</li>
<li>Depending on the situation, the person might freeze in place</li>
Expand Down
3 changes: 0 additions & 3 deletions app/components/PickEmotion/PickEmotion.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ export default class PickEmotion extends Component {
<button className={this.defineClass('scared')} onClick={() => this.pickEmotion('scared')}>
scared
</button>
<button className={this.defineClass('neutral')} onClick={() => this.pickEmotion('neutral')}>
neutral
</button>
</article>
)
}
Expand Down
9 changes: 6 additions & 3 deletions app/components/Play/Play.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export default class Play extends Component {
emotions: [],
canvasURL: ''
}
this.analyzeEmotions = this.analyzeEmotions.bind(this)
this.getImageURL = this.getImageURL.bind(this)
}

getImageURL(url) {
Expand Down Expand Up @@ -43,10 +45,11 @@ export default class Play extends Component {
return (
<article className='play'>
<PickEmotion />
<ImageCapture analyzeEmotions={this.analyzeEmotions.bind(this)}
getImageURL={this.getImageURL.bind(this)}/>
<ImageCapture analyzeEmotions={this.analyzeEmotions}
getImageURL={this.getImageURL}/>
<EmotionResults results={this.state.emotions}
url={this.state.canvasURL} />
url={this.state.canvasURL}
pickedEmotion={this.state.pickedEmotion} />
</article>
)
}
Expand Down

0 comments on commit a59ca72

Please sign in to comment.