Skip to content
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

Victor Freitas #18

Open
wants to merge 23 commits into
base: master
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
indent_size = 2
trim_trailing_whitespace = true

[Makefile]
Expand Down
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_TAROT_CARDS_API=https://assets.vikoder.com/tarot.json
23 changes: 23 additions & 0 deletions .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*
56 changes: 25 additions & 31 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,44 @@
# front-end-challenge
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).

> Desafio para os futuros front-end's do [@Personare](https://github.com/Personare)
## Available Scripts

## Introdução
In the project directory, you can run:

A nossa Product Owner pensou em um produto fantástico para ser desenvolvido, e um dos desafios é criação de um jogo de Tarot.
### `npm start`

<br>
Runs the app in the development mode.<br>
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.

**Então, essa é a sua missão!**
The page will reload if you make edits.<br>
You will also see any lint errors in the console.

Criar um jogo de Tarot, permitindo o sorteio de uma carta.
### `npm test`

E as especificações são:
Launches the test runner in the interactive watch mode.<br>
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.

- Tela de apresentação exibindo todas as cartas com seu conteúdo visível, e com um botão para iniciar o jogo.
- Ao clicar no botão, as cartas deverão ser viradas - escondendo o conteúdo - e embaralhadas.
- Permitir que o usuário selecione apenas uma carta, clicando na mesma.
- Apresentar a carta selecionada, o nome da carta e uma descrição. (a descrição pode ser um lorem ipsum)
### `npm run build`

OBS: As imagens e nomes das cartas estão listadas no arquivo [`tarot.json`](tarot.json), esse arquivo deve ser consumido via _http request_. A propriedade `image` de cada carta deve ser concatenada com a propriedade `imagesUrl`, para obter o endereço final da imagem. Utilize o valor da propriedade `imageBackCard` para obter a imagem do fundo da carta.
Builds the app for production to the `build` folder.<br>
It correctly bundles React in production mode and optimizes the build for the best performance.

The build is minified and the filenames include the hashes.<br>
Your app is ready to be deployed!

## Instruções
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.

1. Efetue o **fork** deste repositório e crie um branch com o seu nome. (ex: caue-alves).
2. Após finalizar o desafio, crie um **Pull Request**.
3. Aguarde algum contribuidor realizar o code review.
### `npm run eject`

**Note: this is a one-way operation. Once you `eject`, you can’t go back!**

## Pré-requisitos
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.

- Aplicação feita em React
- Possuir testes
- Gerar versão de produção
- Criar micro commits ou commits por features
- Detalhar nos comentários dos commits as decisões tomadas.
Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.

You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.

## Diferenciais
## Learn More

- Boa documentação
- Testes de componentes isolados
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).

## Dúvidas

Se surgir alguma dúvida, consulte as [perguntas feitas anteriormente](https://github.com/Personare/front-end-challenge/labels/question).

Caso não encontre a sua resposta, sinta-se à vontade para [abrir uma issue](https://github.com/Personare/front-end-challenge/issues/new) =]
To learn React, check out the [React documentation](https://reactjs.org/).
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "personare-challenge",
"version": "0.1.0",
"private": true,
"dependencies": {
"classnames": "^2.2.6",
"react": "^16.7.0",
"react-dom": "^16.7.0",
"react-redux": "^6.0.0",
"react-scripts": "2.1.1",
"redux": "^4.0.1",
"redux-devtools-extension": "^2.13.7",
"redux-thunk": "^2.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
]
}
Binary file added public/favicon.ico
Binary file not shown.
17 changes: 17 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<title>Tarot do Dia. Veja o conselho para o seu dia.</title>
</head>
<body>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
<div id="root"></div>
</body>
</html>
15 changes: 15 additions & 0 deletions public/manifest.json
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": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
6 changes: 6 additions & 0 deletions src/action-types/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export const TAROT_CARDS_SUCCESS = 'TAROT_CARDS_SUCCESS'
export const TAROT_CARDS_FAIL = 'TAROT_CARDS_FAIL'
export const IS_LOADING = 'IS_LOADING'
export const IS_SHUFFLE = 'IS_SHUFFLE'
export const CURRENT_CARD = 'CURRENT_CARD'
export const TAROT_CARDS_SHUFFLE = 'TAROT_CARDS_SHUFFLE'
23 changes: 23 additions & 0 deletions src/actions/getTarotCards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import request from '../helpers/request'
import parseTarotCards from '../helpers/parseTarotCards'
import {
TAROT_CARDS_SUCCESS,
TAROT_CARDS_FAIL,
IS_LOADING,
} from '../action-types'

const { REACT_APP_TAROT_CARDS_API: TAROT_CARDS_API } = process.env

export default () => async dispatch => {
const { error, ...data } = await request(TAROT_CARDS_API)

dispatch({
type: error ? TAROT_CARDS_FAIL : TAROT_CARDS_SUCCESS,
payload: error ? error : parseTarotCards(data),
})

dispatch({
type: IS_LOADING,
payload: false,
})
}
6 changes: 6 additions & 0 deletions src/actions/setCurrentCard.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { CURRENT_CARD } from '../action-types'

export default card => ({
type: CURRENT_CARD,
payload: card,
})
6 changes: 6 additions & 0 deletions src/actions/setIsLoading.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IS_LOADING } from '../action-types'

export default isLoading => ({
type: IS_LOADING,
payload: isLoading,
})
6 changes: 6 additions & 0 deletions src/actions/setIsShuffle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { IS_SHUFFLE } from '../action-types'

export default isShuffle => ({
type: IS_SHUFFLE,
payload: isShuffle,
})
7 changes: 7 additions & 0 deletions src/actions/setShuffleCards.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { TAROT_CARDS_SHUFFLE } from '../action-types'
import shuffleCards from '../helpers/shuffleCards'

export default ([...cards]) => ({
type: TAROT_CARDS_SHUFFLE,
payload: shuffleCards(cards),
})
6 changes: 6 additions & 0 deletions src/components/App/App.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.app {
background: #fff;
margin: 0 auto;
min-height: 100vh;
width: 100%;
}
19 changes: 19 additions & 0 deletions src/components/App/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react'

import styles from './App.module.css'
import Header from '../layouts/Header'
import Container from '../Container'
import Cards from '../../containers/Cards'
import Overlay from '../../containers/layouts/Overlay'

const App = () => (
<div className={styles.app}>
<Header />
<Container>
<Cards />
</Container>
<Overlay />
</div>
)

export default App
27 changes: 27 additions & 0 deletions src/components/Button/Button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
.button {
background-color: #cc3283;
border-bottom: 3px solid #af3475;
border-left: 0;
border-radius: 3px;
border-right: 0;
border-top: 0;
color: #fff;
cursor: pointer;
font-size: 16px;
font-weight: bold;
outline: none;
padding: 12px;
font-weight: bold;
}

.button:active,
.button:disabled {
border: 0;
margin-top: 3px;
}

.button:disabled {
cursor: initial;
color: #ebebeb;
opacity: 0.5;
}
42 changes: 42 additions & 0 deletions src/components/Button/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import React from 'react'
import PropTypes from 'prop-types'

import styles from './Button.module.css'

const Button = ({
isLoading,
setIsShuffle,
setShuffleCards,
cards,
isShuffle,
text,
}) => {
const handleClick = () => {
setIsShuffle(true)
setShuffleCards(cards)
}

return (
<button
className={styles.button}
onClick={handleClick}
disabled={isLoading || isShuffle || !cards.length}
>
{text}
</button>
)
}
Button.defaultProps = {
text: 'Embaralhar cartas',
}

Button.propTypes = {
isLoading: PropTypes.bool.isRequired,
text: PropTypes.string,
setIsShuffle: PropTypes.func.isRequired,
setShuffleCards: PropTypes.func.isRequired,
isShuffle: PropTypes.bool.isRequired,
cards: PropTypes.array.isRequired,
}

export default Button
Loading