From 7002b27c914f68b980d62e121a7adcefec7d08da Mon Sep 17 00:00:00 2001 From: RobertBatista Date: Fri, 5 Jul 2024 01:26:36 -0300 Subject: [PATCH 1/5] =?UTF-8?q?[Task=2001]=20Configura=C3=A7=C3=A3o=20do?= =?UTF-8?q?=20projeto?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .eslintrc.cjs | 18 + .gitignore | 24 + README.md | 39 +- index.html | 13 + package.json | 29 + public/vite.svg | 1 + src/App.tsx | 97 +++ src/ItemForm/index.tsx | 163 +++++ src/assets/icon.png | Bin 0 -> 1490 bytes src/main.tsx | 12 + src/styles.css | 44 ++ src/vite-env.d.ts | 1 + tsconfig.app.json | 27 + tsconfig.json | 11 + tsconfig.node.json | 13 + vite.config.ts | 7 + yarn.lock | 1407 ++++++++++++++++++++++++++++++++++++++++ 17 files changed, 1889 insertions(+), 17 deletions(-) create mode 100644 .eslintrc.cjs create mode 100644 .gitignore create mode 100644 index.html create mode 100644 package.json create mode 100644 public/vite.svg create mode 100644 src/App.tsx create mode 100644 src/ItemForm/index.tsx create mode 100644 src/assets/icon.png create mode 100644 src/main.tsx create mode 100644 src/styles.css create mode 100644 src/vite-env.d.ts create mode 100644 tsconfig.app.json create mode 100644 tsconfig.json create mode 100644 tsconfig.node.json create mode 100644 vite.config.ts create mode 100644 yarn.lock 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..e4b78eae --- /dev/null +++ b/index.html @@ -0,0 +1,13 @@ + + + + + + + Vite + React + TS + + +
+ + + diff --git a/package.json b/package.json new file mode 100644 index 00000000..2b0811bd --- /dev/null +++ b/package.json @@ -0,0 +1,29 @@ +{ + "name": "vite-project", + "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", + "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.tsx b/src/App.tsx new file mode 100644 index 00000000..b0211291 --- /dev/null +++ b/src/App.tsx @@ -0,0 +1,97 @@ +import { useState } from "react"; + +import styled from "styled-components"; + +import ItemForm, { IItem } from "./ItemForm"; + +const Navbar = styled("div")(() => ({ + backgroundColor: "#2b2b2b", + padding: "1.5rem 0", + borderBottom: "1px solid #232323", +})); + +const Title = styled("h1")(() => ({ + color: "#71bb00", + textAlign: "center", + fontWeight: "bolder", +})); + +const Subtitle = styled("h4")(() => ({ + color: "#5f5f5f", + textAlign: "center", + fontWeight: "light", + textTransform: "uppercase", +})); + +const Container = styled.div` + width: 100%; + margin: 0 auto; + + // extra-small + @media (min-width: 0) { + max-width: 280px; + } + + // small + @media (min-width: 600px) { + max-width: 490px; + } + + // medium + @media (min-width: 900px) { + max-width: 490px; + } + + // large + @media (min-width: 1200px) { + max-width: 490px; + } + + // extra-large + @media (min-width: 1536px) { + max-width: 490px; + } +`; + +function App() { + const [items, setItems] = useState([]); + + const addItem = (item: IItem) => { + setItems([...items, item]); + }; + + return ( +
+ + buildbox + + web challenge + + + + + +
+ {items.map((item, index) => ( +
+

{item.name}

+

{item.description}

+ {item.image && ( + {item.name} + )} +
+ ))} +
+
+
+ ); +} + +export default App; diff --git a/src/ItemForm/index.tsx b/src/ItemForm/index.tsx new file mode 100644 index 00000000..bfcf23dc --- /dev/null +++ b/src/ItemForm/index.tsx @@ -0,0 +1,163 @@ +import { useState } from "react"; + +import styled from "styled-components"; + +import icon from "../assets/icon.png"; + +export interface IItem { + name: string; + description: string; + image: string; +} + +interface IItemForm { + addItem: (item: IItem) => void; +} + +const Card = styled("div")(() => ({ + marginTop: "4rem", + padding: "1.5rem", + border: "1px solid #3b3b3b", + borderRadius: "4px", +})); + +const Input = styled("input")(() => ({ + width: "100%", + padding: "1rem", + border: "none", + borderRadius: "8px", + margin: "0.5rem 0", +})); + +const TextArea = styled("textarea")(() => ({ + width: "100%", + padding: "1rem", + border: "none", + borderRadius: "8px", + margin: "0.5rem 0", +})); + +function ItemForm({ addItem }: IItemForm) { + const [name, setName] = useState(""); + const [description, setDescription] = useState(""); + const [image, setImage] = useState(""); + + const handleClean = () => { + setName(""); + setDescription(""); + setImage(""); + }; + + const handleImageChange = (event: React.ChangeEvent) => { + const file = event.target.files?.[0] as File; + + const reader = new FileReader(); + + reader.onloadend = () => setImage(reader.result as string); + reader.readAsDataURL(file); + }; + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + + addItem({ name, description, image: image }); + + handleClean(); + }; + + return ( + +
+
+ + + {image && ( + + )} + + {!image && ( + + )} +
+ + setName(e.target.value)} + required + /> + +