-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bc36535
commit 57d5e61
Showing
44 changed files
with
27,365 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See https://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# dependencies | ||
/node_modules | ||
|
||
# testing | ||
/coverage | ||
|
||
# production | ||
/build | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "1-rendering", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"firebase": "^5.0.2", | ||
"form-serialize": "^0.7.2", | ||
"react": "^16.3.2", | ||
"react-dom": "^16.3.2", | ||
"react-scripts": "1.1.4", | ||
"sort-by": "^1.2.0" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --env=jsdom", | ||
"eject": "react-scripts eject" | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
} | ||
], | ||
"start_url": "./index.html", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// Exercise: | ||
// | ||
// - Create a chat application using the utility methods we give you | ||
// | ||
// Need some ideas? | ||
// | ||
// - Cause the message list to automatically scroll as new | ||
// messages come in | ||
// - Highlight messages from you to make them easy to find | ||
// - Highlight messages that mention you by your GitHub username | ||
// - Group subsequent messages from the same sender | ||
// - Create a filter that lets you filter messages in the chat by | ||
// sender and/or content | ||
//////////////////////////////////////////////////////////////////////////////// | ||
import React from "react"; | ||
import { render } from "react-dom"; | ||
import { | ||
login, | ||
sendMessage, | ||
subscribeToMessages | ||
} from "./utils"; | ||
import "./index"; | ||
|
||
/* | ||
Here's how to use the ChatUtils: | ||
login((error, user) => { | ||
// hopefully the error is `null` and you have a auth.github object | ||
}) | ||
sendMessage(user, 'hello, this is a message') | ||
const unsubscribe = subscribeToMessages(messages => { | ||
// here are your messages as an array, it will be called | ||
// every time the messages change | ||
}) | ||
unsubscribe() // stop listening for new messages | ||
The world is your oyster! | ||
*/ | ||
|
||
class Chat extends React.Component { | ||
render() { | ||
return ( | ||
<div className="chat"> | ||
<header className="chat-header"> | ||
<h1 className="chat-title">Chat App!</h1> | ||
<p className="chat-message-count"># messages: 3</p> | ||
</header> | ||
<div className="messages"> | ||
<ol className="message-groups"> | ||
<li className="message-group"> | ||
<div className="message-group-avatar"> | ||
<img alt="user avatar" src="https://placekitten.com/200/200"/> | ||
</div> | ||
<ol className="messages"> | ||
<li className="message">So, check it out:</li> | ||
<li className="message">QA Engineer walks into a bar.</li> | ||
<li className="message">Orders a beer.</li> | ||
<li className="message">Orders 0 beers.</li> | ||
<li className="message">Orders 999999999 beers.</li> | ||
<li className="message">Orders a lizard.</li> | ||
<li className="message">Orders -1 beers.</li> | ||
<li className="message">Orders a sfdeljknesv.</li> | ||
</ol> | ||
</li> | ||
<li className="message-group"> | ||
<div className="message-group-avatar"> | ||
<img alt="user avatar" src="https://placekitten.com/300/300"/> | ||
</div> | ||
<ol className="messages"> | ||
<li className="message">Haha</li> | ||
<li className="message">Stop stealing other people's jokes :P</li> | ||
</ol> | ||
</li> | ||
<li className="message-group"> | ||
<div className="message-group-avatar"> | ||
<img alt="user avatar" src="https://placekitten.com/200/200"/> | ||
</div> | ||
<ol className="messages"> | ||
<li className="message">:|</li> | ||
</ol> | ||
</li> | ||
</ol> | ||
</div> | ||
<form className="new-message-form"> | ||
<div className="new-message"> | ||
<input type="text" placeholder="say something..."/> | ||
</div> | ||
</form> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
|
||
render(<Chat />, document.getElementById("root")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
body { | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", | ||
Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", | ||
sans-serif; | ||
} | ||
|
||
html { | ||
box-sizing: border-box; | ||
overflow: hidden; /* prevent elastic scrolling in WebKit */ | ||
} | ||
*, | ||
*:before, | ||
*:after { | ||
box-sizing: inherit; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
line-height: 1.5; | ||
} | ||
|
||
.chat { | ||
height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.chat-header { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: 10px; | ||
background-color: lightblue; | ||
border-bottom: 1px solid #666; | ||
color: #666; | ||
} | ||
.chat-title, | ||
.chat-message-count { | ||
display: inline-block; | ||
margin: 0; | ||
} | ||
.chat-title { | ||
font-size: 1.5em; | ||
} | ||
|
||
.messages { | ||
overflow: auto; | ||
flex: 1; | ||
} | ||
|
||
.new-message-form { | ||
margin: 0; | ||
} | ||
.new-message { | ||
padding: 2px 5px 4px; | ||
border-top: 1px solid #666; | ||
background: white; | ||
} | ||
.new-message input { | ||
border: 0; | ||
width: 100%; | ||
outline: none; | ||
font-size: 1.2em; | ||
padding: 0.5em; | ||
} | ||
|
||
ol.message-groups, | ||
ol.messages { | ||
list-style-type: none; | ||
margin: 0; | ||
padding: 0; | ||
} | ||
|
||
.message-group { | ||
position: relative; | ||
min-height: 40px; | ||
padding: 0 10px; | ||
margin: 10px 0; | ||
} | ||
.message-group-avatar { | ||
position: absolute; | ||
} | ||
.message-group-avatar img { | ||
height: 40px; | ||
} | ||
|
||
ol.messages { | ||
margin-left: 40px; | ||
} | ||
|
||
.message { | ||
padding: 8px 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// Exercise: | ||
// | ||
// - render DATA.title in an <h1> | ||
// - render a <ul> with each of DATA.items as an <li> and display the name | ||
// - limit the list to only mexican food (hint: use DATA.items.filter(...)) | ||
// - sort the items in alphabetical order by name | ||
// (hint: use sort-by https://github.com/staygrimm/sort-by#example) | ||
// | ||
// Got extra time and know some React already? | ||
// - add a select dropdown to make filtering on `type` dynamic | ||
// - add a button to toggle the sort order | ||
// - Hint: you'll need an `updateThePage` function that calls `render`, | ||
// and then you'll need to call it in the event handlers of the form controls | ||
//////////////////////////////////////////////////////////////////////////////// | ||
import "./index.css"; | ||
// import "./lecture"; | ||
// import "./solution"; | ||
import "./exercise"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import React from "react"; | ||
import ReactDOM from "react-dom"; | ||
|
||
class Forms extends React.Component { | ||
render() { | ||
return ( | ||
<div> | ||
<h1>Forms</h1> | ||
<form> | ||
<input type="text" /> | ||
</form> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
ReactDOM.render( | ||
<Forms />, | ||
document.getElementById("root") | ||
); |
Oops, something went wrong.