diff --git a/.eslintrc.cjs b/.eslintrc.cjs new file mode 100644 index 00000000..d6c95379 --- /dev/null +++ b/.eslintrc.cjs @@ -0,0 +1,18 @@ +module.exports = { + root: true, + env: { browser: true, es2020: true }, + extends: [ + 'eslint:recommended', + 'plugin:@typescript-eslint/recommended', + 'plugin:react-hooks/recommended', + ], + ignorePatterns: ['dist', '.eslintrc.cjs'], + parser: '@typescript-eslint/parser', + plugins: ['react-refresh'], + rules: { + 'react-refresh/only-export-components': [ + 'warn', + { allowConstantExport: true }, + ], + }, +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..a547bf36 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.ntvs* +*.njsproj +*.sln +*.sw? diff --git a/README.md b/README.md index f7f95f1b..0d6babed 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,30 @@ -# web-developer-challenge +# React + TypeScript + Vite -Olá! +This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules. -Este desafio consiste em identificar seu conhecimento em desenvolvimento Web, portanto esperamos que você tente resolve-lo usando toda a sua capacidade e conhecimento da tecnologia. +Currently, two official plugins are available: -O Desafio é o seguinte: +- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh +- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh -Monte uma página utilizando React.js que contenha uma lista de posts com a possíbilidade de adicionar e remover. Cada post deve conter nome, mensagem e foto. Não é necessário fazer o Back-End, os dados podem estar apenas em tempo de execução no Front-End. +## Expanding the ESLint configuration -**Projetos que encontramos Typescript, Styled Compoments, Responsividade, terão pontos adicionais!** +If you are developing a production application, we recommend updating the configuration to enable type aware lint rules: -Tente colocar ao máximo todos os recursos técnicos que você conhece, padrão de arquitetura, boas práticas de código, bibliotecas, etc. +- Configure the top-level `parserOptions` property like this: -Você deve fazer um Fork deste repositório e solicitar um Pull Request com seu nome, email e celular na descrição para nossa avaliação e contato. +```js +export default { + // other rules... + parserOptions: { + ecmaVersion: 'latest', + sourceType: 'module', + project: ['./tsconfig.json', './tsconfig.node.json'], + tsconfigRootDir: __dirname, + }, +} +``` -Abaixo segue o link do XD com protótipo navegável para conhecer a dinâmica da interface e os dados para Logar no Zeplin para ter acesso ao Design com suas medidas. - - -## Design para o Desafio -https://adobe.ly/2BVcy5C - -https://xd.adobe.com/view/89306ae3-6b1a-4574-a495-12b5280914e6-dc63/grid - -![footer](https://cdn-images-1.medium.com/max/2600/1*_DOHv30w-0eI-Ysz5U47Yg.png) +- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked` +- Optionally add `plugin:@typescript-eslint/stylistic-type-checked` +- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list diff --git a/index.html b/index.html new file mode 100644 index 00000000..53b30377 --- /dev/null +++ b/index.html @@ -0,0 +1,16 @@ + + + + + + + + Vite + React + TS + + + +
+ + + + \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 00000000..acc45f8f --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "web-developer-challenge", + "private": true, + "version": "0.0.0", + "type": "module", + "scripts": { + "dev": "vite", + "build": "tsc -b && vite build", + "lint": "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0", + "preview": "vite preview" + }, + "dependencies": { + "react": "^18.3.1", + "react-dom": "^18.3.1", + "react-icons": "^5.2.1", + "styled-components": "^6.1.11" + }, + "devDependencies": { + "@types/react": "^18.3.3", + "@types/react-dom": "^18.3.0", + "@typescript-eslint/eslint-plugin": "^7.13.1", + "@typescript-eslint/parser": "^7.13.1", + "@vitejs/plugin-react-swc": "^3.5.0", + "eslint": "^8.57.0", + "eslint-plugin-react-hooks": "^4.6.2", + "eslint-plugin-react-refresh": "^0.4.7", + "typescript": "^5.2.2", + "vite": "^5.3.1" + } +} diff --git a/public/vite.svg b/public/vite.svg new file mode 100644 index 00000000..e7b8dfb1 --- /dev/null +++ b/public/vite.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/App/Feed/feed.styles.ts b/src/App/Feed/feed.styles.ts new file mode 100644 index 00000000..3f6227e6 --- /dev/null +++ b/src/App/Feed/feed.styles.ts @@ -0,0 +1,66 @@ +import styled from "styled-components"; + +export const Card = styled("div")(() => ({ + position: "relative", + padding: "1.5rem", + marginBottom: "1rem", + border: "1px solid #3b3b3b", + borderRadius: "4px", + backgroundColor: "#313131", +})); + +export const CardContent = styled("div")(() => ({ + marginTop: "1.8rem", + display: "flex", + gap: "1.5rem", +})); + +export const Text = styled("p")(() => ({ + color: "#7a7a7a", +})); + +export const TextLabel = styled.p` + color: #595959; + + // extra-small + @media (min-width: 0) { + fontsize: 8pt; + } + + // small + @media (min-width: 600px) { + fontsize: 10pt; + } +`; + +export const ImageContainer = styled.div` + border-radius: 40%; + + // extra-small + @media (min-width: 0) { + width: 50px; + height: 50px; + } + + // small + @media (min-width: 600px) { + width: 90px; + height: 90px; + } +`; + +export const Image = styled.img` + border-radius: 40%; + + // extra-small + @media (min-width: 0) { + width: 50px; + height: 50px; + } + + // small + @media (min-width: 600px) { + width: 90px; + height: 90px; + } +`; diff --git a/src/App/Feed/feed.tsx b/src/App/Feed/feed.tsx new file mode 100644 index 00000000..21495a07 --- /dev/null +++ b/src/App/Feed/feed.tsx @@ -0,0 +1,65 @@ +import { IoMdCloseCircleOutline } from "react-icons/io"; + +import { IconButton } from "../../components/IconButton"; +import { ItemProps } from "../ItemForm/itemform"; + +import { + Card, + CardContent, + Image, + ImageContainer, + Text, + TextLabel, +} from "./feed.styles"; + +interface FeedProps { + items: ItemProps[]; + setItems: React.Dispatch>; +} + +export default function Feed({ items, setItems }: FeedProps) { + const handleRemoveItem = (index: number) => { + const newItems = items.filter((_item, indexItem) => { + return indexItem !== index; + }); + + setItems(newItems); + }; + + return ( +
+

Feed

+ + {items.map((item, index) => ( + + handleRemoveItem(index)} + style={{ + position: "absolute", + margin: "8px", + top: 0, + right: 0, + }} + > + + + + + + {item.name} + + +
+ {item.description} + +
+ Enviado por + {item.name} +
+
+
+
+ ))} +
+ ); +} diff --git a/src/App/ItemForm/itemform.styles.ts b/src/App/ItemForm/itemform.styles.ts new file mode 100644 index 00000000..c1705dfe --- /dev/null +++ b/src/App/ItemForm/itemform.styles.ts @@ -0,0 +1,16 @@ +import styled from "styled-components"; + +export const Card = styled("div")(() => ({ + marginTop: "8rem", + padding: "1.5rem", + border: "1px solid #3b3b3b", + borderRadius: "4px", + backgroundColor: "#313131", +})); + +export const CardButtons = styled("div")(() => ({ + display: "flex", + justifyContent: "flex-end", + gap: "1.5rem", + marginTop: "1.6rem", +})); diff --git a/src/App/ItemForm/itemform.tsx b/src/App/ItemForm/itemform.tsx new file mode 100644 index 00000000..72bb94f0 --- /dev/null +++ b/src/App/ItemForm/itemform.tsx @@ -0,0 +1,110 @@ +import { useState } from "react"; + +import UploadImage from "../../components/UploadImage"; +import { Button } from "../../components/Button"; +import { Input } from "../../components/Input"; +import { TextArea } from "../../components/TextArea"; + +import { Card, CardButtons } from "./itemform.styles"; + +export interface ItemProps { + name: string; + description: string; + image: string; +} + +interface ItemFormProps { + addItem: (item: ItemProps) => void; +} + +export default function ItemForm({ addItem }: ItemFormProps) { + const [item, setItem] = useState({} as ItemProps); + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + + addItem({ + name: item.name, + description: item.description, + image: item.image, + }); + + handleClean(); + }; + + const handleImageChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0] as File; + + const reader = new FileReader(); + + reader.onloadend = () => { + setItem((prev) => ({ + ...prev, + image: reader.result as string, + })); + }; + reader.readAsDataURL(file); + }; + + const handleCleanImage = () => { + setItem((prev) => ({ + ...prev, + image: "", + })); + }; + + const handleOnChange = ( + event: React.ChangeEvent + ) => { + setItem((prev) => ({ + ...prev, + [event.target.name]: event.target.value, + })); + }; + + const handleClean = () => { + setItem({ + name: "", + description: "", + image: "", + }); + }; + + return ( + +
+ + + + +