Skip to content

Commit

Permalink
Initial set up
Browse files Browse the repository at this point in the history
  • Loading branch information
KittyGiraudel committed May 1, 2017
0 parents commit 91b562e
Show file tree
Hide file tree
Showing 28 changed files with 1,010 additions and 0 deletions.
18 changes: 18 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
node_modules

# testing
coverage

# production
build

# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

21 changes: 21 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "foobar",
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-scripts": "0.9.5"
},
"dependencies": {
"prop-types": "^15.5.8",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
Binary file added public/favicon.ico
Binary file not shown.
31 changes: 31 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!--
Notice the use of %PUBLIC_URL% in the tag 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>
<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`.
To create a production bundle, use `npm run build`.
-->
</body>
</html>
17 changes: 17 additions & 0 deletions src/CompleteProps/User.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import React from 'react'
import PropTypes from 'prop-types'

const User = (props) => (
<p>
{props.preferredName || props.name}: <a href={`mailto:${props.email}`}>{props.email}</a>
</p>
)

// https://facebook.github.io/react/docs/typechecking-with-proptypes.html
User.propTypes = {
name: PropTypes.string.isRequired,
email: PropTypes.string.isRequired,
preferredName: PropTypes.string
}

export default User
20 changes: 20 additions & 0 deletions src/CompleteProps/UserList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react'
import PropTypes from 'prop-types'
import User from './User'

const UserList = (props) => (
<ul>
{props.users.map((user) => (
<li key={user.email}>
<User {...user} />
</li>
))}
</ul>
)

// https://facebook.github.io/react/docs/typechecking-with-proptypes.html
UserList.propTypes = {
users: PropTypes.array.isRequired
}

export default UserList
16 changes: 16 additions & 0 deletions src/CompleteProps/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react'
import UserList from './UserList'

const users = [
{ name: 'Michael', preferredName: 'Mike', email: '[email protected]' },
{ name: 'Hugo', email: '[email protected]' }
]

const UserIndex = () => (
<div>
<h2>Users:</h2>
<UserList users={users} />
</div>
)

export default UserIndex
30 changes: 30 additions & 0 deletions src/Forms/container.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react'
import PropTypes from 'prop-types'
import UserList from '../CompleteProps/UserList'

class Search extends React.Component {
static propTypes = {
users: PropTypes.arrayOf(PropTypes.object).isRequired,
search: PropTypes.string
}

getFilteredUsers = () => {
if (!this.props.search) {
return this.props.users
}

return this.props.users.filter(this.isUserMatching)
}

isUserMatching = (user) => {
return user.name.toLowerCase().indexOf(this.props.search.toLowerCase()) > -1
}

render () {
return (
<UserList users={this.getFilteredUsers()} />
)
}
}

export default Search
Loading

0 comments on commit 91b562e

Please sign in to comment.