Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Adiciona página junte-se com renderização de arquivo MarkDown #86

Merged
merged 5 commits into from
Oct 5, 2019
Merged
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.1.2",
"eslint-plugin-react": "^7.11.1",
"file-loader": "^4.2.0",
"flow-bin": "^0.85.0",
"html-webpack-plugin": "^3.2.0",
"husky": "^1.1.3",
Expand All @@ -48,8 +49,10 @@
"dependencies": {
"axios": "^0.18.0",
"blueprint-css": "^3.0.0-beta.0",
"prop-types": "^15.7.2",
"react": "^16.6.0",
"react-dom": "^16.6.0",
"react-markdown": "^4.2.2",
"react-router-dom": "^4.3.1",
"react-tooltip": "^3.11.1"
}
Expand Down
1 change: 1 addition & 0 deletions src/components/app/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const AppHeader = () => (

<HeaderWrapperNavLinks>
<HeaderNavLink to="/quem-somos">Quem Somos?</HeaderNavLink>
<HeaderNavLink to="/junte-se">Junte-se!</HeaderNavLink>
<HeaderNavLink to="/contribuir">Contribuir</HeaderNavLink>
</HeaderWrapperNavLinks>
</Header>
Expand Down
2 changes: 2 additions & 0 deletions src/components/app/Routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import React from 'react';
import { Switch, Route } from 'react-router-dom';
import ProjectsPage from '../projects/ProjectsPage';
import JoinUsPage from '../joinus/JoinUsPage';

const Routes = () => (
<Switch>
<Route exact path="/" component={ProjectsPage} />
<Route path="/quem-somos" render={() => <div />} />
<Route path="/junte-se" component={JoinUsPage} />
<Route path="/contribuir" render={() => <div />} />
</Switch>
);
Expand Down
2 changes: 1 addition & 1 deletion src/components/commons/header/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
*/

.nav-option {
margin: 0;
margin: 10px;
width: fit-content;
}

Expand Down
9 changes: 9 additions & 0 deletions src/components/commons/renderer/MarkDownRenderer.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.markdown a {
color: #0366d6;
}

.markdown code {
background-color: rgba(27, 31, 35, 0.05);
border-radius: 20%;
padding: 0.2em 0.4em;
}
14 changes: 14 additions & 0 deletions src/components/commons/renderer/MarkDownRenderer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from 'react';
import ReactMarkdown from 'react-markdown';
import PropTypes from 'prop-types';
import './MarkDownRenderer.css';

const MarkDownRenderer = ({ markDownText }) => (
<ReactMarkdown source={markDownText} className="markdown" />
);

MarkDownRenderer.propTypes = {
markDownText: PropTypes.string.isRequired,
};

export default MarkDownRenderer;
23 changes: 23 additions & 0 deletions src/components/joinus/JoinUs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Junte-se a nós!

Um dos objetivos principais do OpenDevUFCG é ajudar os projetos open source feitos e apoiados por estudantes de Ciência da Computação da UFCG a atrair contribuições.

### Tem um projeto open source e deseja impulsioná-lo?

O **IssueAi** tem o intuito de ser um espaço que promove a ajuda e colaboração de alunos para alunos através da exposição dos seus respectivos projetos para a comunidade da UFCG, fazendo crescer o espírito open source dentro do nosso ambiente acadêmico.

Para ajudar ainda mais a atingir tal objetivo, orientamos que todo projeto tenha:

- Um bom README. É importante tentar fazer as pessoas não terem medo da primeira contribuição que é a mais importante de todas, por isso seja claro, simples e amigável, é a chave para atrair contribuições.

- Uma [licença](https://choosealicense.com/) Open Source.

- Código de conduta. É preciso garantir um ambiente acolhedor e respeitável para todos.

- Guia de contribuição. Uma boa documentação dos passos a serem seguidores para o uso do projeto tem que ser prioridade. Tente ser claro e direto, use o auxílio de outras documentações como hyperlinks.

Para se aprofundar ainda mais no assunto, recomenda-se a leitura do [open source guide](https://opensource.guide/starting-a-project/).

### Para adicionar um projeto

Os dados dos repositórios usados para mostrar são recuperados a partir dos arquivos contidos no diretório `data/`. Para adicionar seu repositório aos nossos projetos apoiados, abra uma Pull Request com os dados do seu repositório em `data/repositories.js`, você pode acessá-lo [clicando aqui](https://github.com/OpenDevUFCG/IssueAi/blob/master/data/repositories.js).
26 changes: 26 additions & 0 deletions src/components/joinus/JoinUsPage.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React, { useState, useEffect } from 'react';
import MarkDownRenderer from '../commons/renderer/MarkDownRenderer';
import joinUsFile from './JoinUs.md';

const JoinUsPage = () => {
const [markDownText, setMarkDownText] = useState('');
Copy link
Contributor

@fanny fanny Oct 5, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why you put in a state? The markdown is static, so we don't need a state here, imo.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By using a state, the page will render while the MarkDown text is being obtained by fetch, and also I can pass its value as props for MarkDownRenderer component.


useEffect(() => {
async function fetchFileAndSetState() {
const response = await fetch(joinUsFile);
const text = await response.text();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this await is really necessary? because, in my understanding response will have a value when arrive at this line

Suggested change
const text = await response.text();
const text = response.text();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fetch returns a Response object, and its body is a Readable Stream. In the same way we need to use json async method when we want this response's body as a JSON, in this case it's necessary to get the body as a text, so I decided to use text method.

setMarkDownText(text);
}

fetchFileAndSetState();
}, []);

return (
<section>
<MarkDownRenderer markDownText={markDownText} />
<br />
</section>
);
};

export default JoinUsPage;
9 changes: 9 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ const config = {
'css-loader',
],
},
{
test: /\.(eot|md|svg|ttf|woff|woff2)$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[ext]',
},
},
},
],
},
plugins: [
Expand Down
Loading