-
Notifications
You must be signed in to change notification settings - Fork 0
added the t.hanks component to the end of the presentation #1
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| .thanks-container { | ||
| margin-top: 10px; | ||
| } | ||
| .thanks-row { | ||
| margin: 0 auto; | ||
| display: flex; | ||
| justify-content: space-between; | ||
| } | ||
|
|
||
| .thanks__img { | ||
| max-width: 100%; | ||
| max-height: 100%; | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import React from 'react'; | ||
|
|
||
| import Link from './Link'; | ||
| import './Thanks.css'; | ||
| import meme from '../assets/tomhanksmeme.jpg'; | ||
|
|
||
| export default class Thanks extends React.Component { | ||
| static MAX_HANKS = 40; | ||
|
|
||
| constructor() { | ||
| super(); | ||
| this.state.message = 'T.hanks'; | ||
| this.state.numOfHanks = 1; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: prefer |
||
| } | ||
|
|
||
| clickHandler = () => { | ||
| if (this.state.numOfHanks < Thanks.MAX_HANKS) { | ||
| this.setState({ | ||
| message: 'T.hanks a lot!', | ||
| numOfHanks: this.state.numOfHanks * 2, | ||
| }); | ||
| } | ||
| }; | ||
|
|
||
| render() { | ||
| const HanksByRow = []; | ||
| for (let i = 1; i <= this.state.numOfHanks; i++) { | ||
| const currHanksRow = []; | ||
| for (let j = 1; j <= this.state.numOfHanks; j *= 2) { | ||
| currHanksRow.push( | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: prefer lowerCamelCase for var names |
||
| tHanksMeme({ | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: component names are UpperCamelCase, this should be an explicit render e.g. |
||
| key: i, | ||
| onClick: () => { | ||
| this.clickHandler(); | ||
| }, | ||
| }) | ||
| ); | ||
| } | ||
| HanksByRow.push(currHanksRow); | ||
| } | ||
|
|
||
| return ( | ||
| <div class="thanks-component"> | ||
| <h1>{this.state.message}</h1> | ||
| <Link to="https://github.com/nickav/react"> | ||
| https://github.com/nickav/react | ||
| </Link> | ||
| <div class="thanks-container"> | ||
| {HanksByRow.map((row) => ( | ||
| <div class="thanks-row">{row}</div> | ||
| ))} | ||
| </div> | ||
| </div> | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| const tHanksMeme = (props) => ( | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: make this a static property of the |
||
| <div class="thanks__image-wrapper"> | ||
| <img | ||
| src={meme} | ||
| alt="t.hanks meme of tom hanks" | ||
| class="thanks__img" | ||
| {...props} | ||
| /> | ||
| </div> | ||
| ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: ^ use prettier to format files