This repository has been archived by the owner on May 28, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from OpenDevUFCG/feat/mentors-page
Feat/mentors page
- Loading branch information
Showing
9 changed files
with
269 additions
and
30 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,41 @@ | ||
{ | ||
"org": "OpenDevUFCG", | ||
"repositories": [ | ||
{ | ||
"name": "calluswhatyouwant/spotify-web-sdk", | ||
"difficulty": "avancado" | ||
}, | ||
{ | ||
"name": "calluswhatyouwant/musicritic", | ||
"difficulty": "avancado" | ||
}, | ||
{ | ||
"name": "paulojbleitao/pokedex", | ||
"difficulty": "intermediario" | ||
}, | ||
{ | ||
"name": "SubmiBot/SubmiBot", | ||
"difficulty": "intermediario" | ||
}, | ||
{ | ||
"name": "marianabianca/pomodoro", | ||
"difficulty": "iniciante" | ||
}, | ||
{ | ||
"name": "P-Sync/P-Sync", | ||
"difficulty": "intermediario" | ||
}, | ||
{ | ||
"name": "FelipeMarinho97/iskra-webkit-greeter", | ||
"difficulty": "intermediario" | ||
}, | ||
{ | ||
"name": "Rickecr/PyGraph", | ||
"difficulty": "intermediario" | ||
}, | ||
{ | ||
"name": "Rickecr/CamaraDosDeputados", | ||
"difficulty": "iniciante" | ||
} | ||
] | ||
} |
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
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,56 @@ | ||
.img-mentor { | ||
border-radius: 100%; | ||
width: 200px; | ||
filter: grayscale(100%); | ||
transition: all 0.7s ease; | ||
} | ||
|
||
.card-mentor:hover .img-mentor { | ||
filter: grayscale(0%); | ||
} | ||
|
||
.name-mentor { | ||
color: rgb(46, 46, 46); | ||
margin-top: 20px; | ||
font-size: 18px; | ||
font-weight: bolder; | ||
} | ||
|
||
.card-mentor { | ||
padding: 30px 50px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
border-radius: 5px; | ||
} | ||
|
||
.card-mentor:hover { | ||
background-color: white; | ||
box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.11); | ||
} | ||
.repository-mentor { | ||
background-color: rgb(114, 161, 214); | ||
border-radius: 30px; | ||
padding: 3px 10px; | ||
font-size: 11px; | ||
margin: 3px 3px; | ||
color: white; | ||
font-weight: bolder; | ||
} | ||
|
||
.repository-list-mentor { | ||
visibility: hidden; | ||
list-style-type: none; | ||
display: flex; | ||
flex-flow: row wrap; | ||
text-align: center; | ||
justify-content: center; | ||
padding: 0; | ||
opacity: 0; | ||
transition: opacity 0.7s; | ||
} | ||
|
||
.card-mentor:hover .repository-list-mentor { | ||
visibility: visible; | ||
opacity: 1; | ||
} |
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,25 @@ | ||
// @flow | ||
import React from 'react'; | ||
import type { Repository } from '../commons/repository/repository'; | ||
import type { Mentor as MentorCardProps } from './mentor'; | ||
|
||
import './MentorCard.css'; | ||
|
||
const renderRepositories = (repositoriesList: Repository[]) => | ||
repositoriesList.map(repository => ( | ||
<li className="repository-mentor" key={repository.nameWithOwner}> | ||
{repository.nameWithOwner} | ||
</li> | ||
)); | ||
|
||
const MentorCard = ({ name, imgUrl, repositoriesList }: MentorCardProps) => ( | ||
<div className="card-mentor"> | ||
<img className="img-mentor" src={imgUrl} alt={name} /> | ||
<figcaption className="name-mentor">{name}</figcaption> | ||
<ul className="repository-list-mentor"> | ||
{renderRepositories(repositoriesList)} | ||
</ul> | ||
</div> | ||
); | ||
|
||
export default MentorCard; |
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,24 @@ | ||
// @flow | ||
import React from 'react'; | ||
import type { Mentor } from './mentor'; | ||
|
||
import MentorCard from './MentorCard'; | ||
|
||
type MentorGridProps = { | ||
mentorsList: Mentor[], | ||
}; | ||
|
||
const renderMentors = (mentorsList: Mentor[]) => | ||
mentorsList.map(mentor => ( | ||
<MentorCard | ||
name={mentor.name} | ||
imgUrl={mentor.imgUrl} | ||
repositoriesList={mentor.repositoriesList} | ||
/> | ||
)); | ||
|
||
const MentorGrid = ({ mentorsList }: MentorGridProps) => ( | ||
<ul>{renderMentors(mentorsList)}</ul> | ||
); | ||
|
||
export default MentorGrid; |
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,8 @@ | ||
// @flow | ||
import type { Repository } from '../commons/repository/repository'; | ||
|
||
export type Mentor = { | ||
name: string, | ||
imgUrl: string, | ||
repositoriesList: Repository[], | ||
}; |
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,55 @@ | ||
// @flow | ||
|
||
const repoStatsQuery = ` | ||
fragment SearchResultFields on SearchResultItemConnection { | ||
nodes { | ||
... on Repository { | ||
nameWithOwner | ||
description | ||
url | ||
forkCount | ||
object(expression: "master") { | ||
... on Commit { | ||
history { | ||
totalCount | ||
} | ||
} | ||
} | ||
issues(states: OPEN) { | ||
totalCount | ||
} | ||
pullRequests(states: OPEN) { | ||
totalCount | ||
} | ||
stargazers { | ||
totalCount | ||
} | ||
} | ||
} | ||
}`; | ||
|
||
const searchRepoQuery = ( | ||
query: string, | ||
quantity: number, | ||
after: string | any = null | ||
) => { | ||
let customAfter = after; | ||
if (after) customAfter = `"${after}"`; | ||
return `{ | ||
search( | ||
first: ${quantity}, | ||
after: ${customAfter}, | ||
query: "${query}", | ||
type: REPOSITORY | ||
) { | ||
...SearchResultFields | ||
repositoryCount | ||
pageInfo { | ||
endCursor | ||
hasNextPage | ||
} | ||
} | ||
} ${repoStatsQuery}`; | ||
}; | ||
|
||
export default searchRepoQuery; |
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 |
---|---|---|
@@ -1,34 +1,57 @@ | ||
// @flow | ||
import axios from 'axios'; | ||
import projects from '../../data/repositories.json'; | ||
import searchRepoQuery from '../graphql/queries'; | ||
|
||
const getAxiosInstance = () => { | ||
const token = process.env.GITHUB_TOKEN || ''; | ||
const config = { | ||
baseURL: 'https://laguinho.opendevufcg.org/v1', | ||
baseURL: 'https://api.github.com', | ||
headers: { Authorization: `Bearer ${token}` }, | ||
}; | ||
|
||
return axios.create(config); | ||
}; | ||
|
||
const requestGithub = async (after: string | any) => { | ||
const response = await getAxiosInstance().get('/repositorios', { | ||
params: { | ||
apos: after, | ||
quantidade: 6, | ||
}, | ||
}); | ||
return response; | ||
export const requestGithub = async (query: string, variables: any = {}) => { | ||
const params = { query, variables }; | ||
const response = await getAxiosInstance().post('/graphql', params); | ||
return response.data; | ||
}; | ||
|
||
const getRepositories = async (after: string | any) => { | ||
const response = await requestGithub(after); | ||
const { repos, endCursor } = response.data; | ||
const transformRepository = (githubJson: any) => ({ | ||
nameWithOwner: githubJson.nameWithOwner, | ||
description: githubJson.description, | ||
url: githubJson.url, | ||
forkCount: githubJson.forkCount, | ||
commitsCount: githubJson.object.history.totalCount, | ||
issuesCount: githubJson.issues.totalCount, | ||
pullRequestsCount: githubJson.pullRequests.totalCount, | ||
stargazersCount: githubJson.stargazers.totalCount, | ||
}); | ||
|
||
const getRepositories = async (after: string | any, quantity: number = 6) => { | ||
const { repositories } = projects; | ||
|
||
let query = repositories.reduce( | ||
(accum, current) => ` ${accum} repo:${current.name}`, | ||
'' | ||
); | ||
query = `org:${projects.org}${query}`; | ||
|
||
const response = await requestGithub( | ||
searchRepoQuery(query, quantity, after) | ||
); | ||
|
||
const { | ||
nodes: repos, | ||
pageInfo: { endCursor }, | ||
} = response.data.search; | ||
|
||
let lastCursor = endCursor; | ||
|
||
if (lastCursor) lastCursor = lastCursor.replace('=', ''); | ||
if (!lastCursor) lastCursor = after; | ||
|
||
return { repos, lastCursor }; | ||
return { repos: repos.map(transformRepository), lastCursor }; | ||
}; | ||
|
||
export default getRepositories; |
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