Skip to content

Kelsey Nielsen #339

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
23 changes: 23 additions & 0 deletions github-user-card/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# 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*
16,391 changes: 16,391 additions & 0 deletions github-user-card/package-lock.json

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions github-user-card/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "github-user-card",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.9",
"@testing-library/react": "^11.2.5",
"@testing-library/user-event": "^12.7.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.2",
"web-vitals": "^1.1.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
11 changes: 11 additions & 0 deletions github-user-card/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Github User Cards</title>
</head>
<body>
<div id="root"></div>
</body>
</html>
72 changes: 72 additions & 0 deletions github-user-card/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import React from 'react';
import axios from 'axios';
import User from './components/user';
import Followers from './components/followers';
import Search from './components/search';
import { CssBaseline } from '@material-ui/core';
import { StyledContainer, Heading, FollowersContainer } from './components/styles';

class App extends React.Component {
constructor(){
super();
this.state = {
username: 'kwnie',
userData: [],
followers: []
}
};

componentDidMount = () => {
this.search(this.state.username)
};

componentDidUpdate = (prevProps, prevState) => {
if(prevState.userData !== this.state.userData){
console.log('userdata has changed')
}
};

search = username => {

axios.get(`https://api.github.com/users/${username}`)
.then(res => this.setState({
...this.state,
userData: [res.data]
}))

axios.get(`https://api.github.com/users/${username}/followers`)
.then(res => this.setState({
...this.state,
followers: res.data
})
)
.catch(err => console.log(err))
};

render(){
return (
<StyledContainer>
<CssBaseline />

<Heading>Github User Cards</Heading>

<Search search={this.search} />

{this.state.userData && this.state.userData.map((user, index) => {
return <User key={index} user={user}/>
})}

<Heading>Followers</Heading>

<FollowersContainer>
{this.state.followers && this.state.followers.map((follower, index) => {
return <Followers key={index} follower={follower} />
})}
</FollowersContainer>

</StyledContainer>
);
}
}

export default App;
23 changes: 23 additions & 0 deletions github-user-card/src/components/followers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from 'react';
import { StyledCard, FollowerAvatar, StyledCardContent, StyledTypography } from './styles';

class Followers extends React.Component {
render(){

const { follower } = this.props;

return (
<StyledCard>
<StyledCardContent>

<FollowerAvatar src={follower.avatar_url} alt='avatar' />

<StyledTypography>{follower.login}</StyledTypography>

</StyledCardContent>
</StyledCard>
)
}
}

export default Followers;
45 changes: 45 additions & 0 deletions github-user-card/src/components/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
// import { SearchContainer } from './styles';
// import { Input } from '@material-ui/core';
// import SearchIcon from '@material-ui/icons/Search';

class Search extends React.Component {

constructor() {
super();
this.state = {
username: ""
}
}

handleChange = (e) => {
this.setState({
...this.state,
username: e.target.value
})
}

handleSubmit = (e) => {
e.preventDefault();
this.props.search(this.state.username);
this.setState({
...this.state,
username: ""
})
}

render(){
return (
<form onSubmit={this.handleSubmit}>
{/* <SearchIcon /> */}
<input
placeholder="Search…"
onChange={this.handleChange}
value={this.state.username}
type="text" />
</form>
)
}
};

export default Search;
70 changes: 70 additions & 0 deletions github-user-card/src/components/styles.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { styled } from '@material-ui/core/styles';
import { Container, Typography, Card, Avatar, FormControl } from '@material-ui/core';

export const StyledContainer = styled(Container) ({
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
background: "url('https://cdn.pixabay.com/photo/2020/06/12/09/30/code-5289831_1280.jpg') no-repeat center center fixed",
'-webkit-background-size': 'cover',
'-moz-background-size': 'cover',
'-o-background-size': 'cover',
backgroundSize: 'cover',
padding: 0,
});

export const FollowersContainer = styled(Container) ({
display: 'flex',
flexDirection: 'row',
flexWrap: 'wrap',
justifyContent: 'center',
});

export const Heading = styled(Container) ({
backgroundColor: 'white',
width: '100%',
padding: '2%',
fontSize: '40px',
display: 'flex',
justifyContent: 'center',
});

export const StyledCard = styled(Card)({
width: '25%',
padding: '1%',
margin: '2%',
});

export const StyledCardContent = styled(Typography) ({
padding: '1%',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
})

export const UserAvatar = styled(Avatar) ({
width: '60%',
height: '60%',
})

export const FollowerAvatar = styled(Avatar) ({
width: '30%',
height: '30%',
})

export const StyledTypography = styled(Typography) ({
fontSize: '18px',
padding: '5%',
})

export const SearchContainer = styled(FormControl) ({
backgroundColor: 'white',
width: '40%',
display: 'flex',
flexDirection: 'row',
justifyContent: 'center',
padding: '1%',
margin: '3%',
outline: '1px solid'
})

32 changes: 32 additions & 0 deletions github-user-card/src/components/user.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { StyledCard, StyledCardContent, UserAvatar, StyledTypography } from './styles';
import { Container } from '@material-ui/core';

class User extends React.Component {
render(){

const { user } = this.props;

return (
<StyledCard>
<StyledCardContent>

<UserAvatar src={user.avatar_url} alt='avatar' />

<Container>
<StyledTypography>{user.name}</StyledTypography>
<StyledTypography>{user.login}</StyledTypography>
<StyledTypography>{user.bio}</StyledTypography>
<StyledTypography>{user.location}</StyledTypography>
<StyledTypography>Followers: {user.followers}</StyledTypography>
<StyledTypography>Following: {user.following}</StyledTypography>
</Container>


</StyledCardContent>
</StyledCard>
);
}
}

export default User;
8 changes: 8 additions & 0 deletions github-user-card/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import ReactDOM from 'react-dom';
import App from './App';

ReactDOM.render(
<App />,
document.getElementById('root')
);
1 change: 1 addition & 0 deletions node_modules/.bin/loose-envify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions node_modules/@babel/runtime/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions node_modules/@babel/runtime/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading