From da8a37dfbd2665c13ba7c101b0c513e7a0a8797f Mon Sep 17 00:00:00 2001 From: Dm1tr1y147 Date: Sat, 28 Nov 2020 13:00:49 +0500 Subject: [PATCH] Removed rubbish --- README.md | 5 ++--- components/ExampleComponent.jsx | 9 -------- components/PowerfulComponent/handlers.js | 11 ---------- components/PowerfulComponent/index.js | 26 ------------------------ context/counterContext.js | 22 -------------------- pages/counter.tsx | 15 -------------- pages/index.tsx | 17 ---------------- styles/exampleComponent.module.css | 6 ------ styles/globals.css | 16 --------------- 9 files changed, 2 insertions(+), 125 deletions(-) delete mode 100644 components/ExampleComponent.jsx delete mode 100644 components/PowerfulComponent/handlers.js delete mode 100644 components/PowerfulComponent/index.js delete mode 100644 context/counterContext.js delete mode 100644 pages/counter.tsx delete mode 100644 pages/index.tsx delete mode 100644 styles/exampleComponent.module.css delete mode 100644 styles/globals.css diff --git a/README.md b/README.md index 05f2182..68a958d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,2 @@ -# ugra-hackathon_frontend - -Training project to get another members of team used to code style +# KOMAP +Сервис для составления маршрутов \ No newline at end of file diff --git a/components/ExampleComponent.jsx b/components/ExampleComponent.jsx deleted file mode 100644 index ccd8082..0000000 --- a/components/ExampleComponent.jsx +++ /dev/null @@ -1,9 +0,0 @@ -import React from "react"; - -import styles from "styles/exampleComponent.module.css"; - -const ExampleComponent = () => { - return ; -}; - -export default ExampleComponent; diff --git a/components/PowerfulComponent/handlers.js b/components/PowerfulComponent/handlers.js deleted file mode 100644 index 537bdc0..0000000 --- a/components/PowerfulComponent/handlers.js +++ /dev/null @@ -1,11 +0,0 @@ -// Лучше писать документацию на функции, за это будет респект от менторов -/** - * Increase counter - * @param {SetStateAction} setCounter - */ -const handleCounterClick = (setCounter) => { - return () => setCounter((prev) => prev + 1); // Если используем контекст, тогда замыкаем всё, что нужно внутри обработчика -}; - -// Экспорт лучше делать отдельно, чтобы всегда знать, что мы экспортируем из файла, а что используем внутри (как с public/private методами) -export { handleCounterClick }; diff --git a/components/PowerfulComponent/index.js b/components/PowerfulComponent/index.js deleted file mode 100644 index 0fb9493..0000000 --- a/components/PowerfulComponent/index.js +++ /dev/null @@ -1,26 +0,0 @@ -import React, { useCallback, useContext } from "react"; - -import { CounterContext } from "context/counterContext"; -import { handleCounterClick } from "./handlers"; // Обработчики событий лучше держать в отдельном файле или использовать кастомные хуки - -/** - * Complex component with counter with context in it - */ -const PowerfulComponent = () => { - const context = useContext(CounterContext); - - console.log(context); - - const handleClick = useCallback(handleCounterClick(context.setCounter), [ - context.setCounter, - ]); - - return ( -
-

{context?.counter}

- -
- ); -}; - -export default PowerfulComponent; diff --git a/context/counterContext.js b/context/counterContext.js deleted file mode 100644 index dec904e..0000000 --- a/context/counterContext.js +++ /dev/null @@ -1,22 +0,0 @@ -import React, { useEffect, useMemo, useState } from "react"; - -const CounterContext = React.createContext(null); - -const initialContext = 0; - -const CounterProvider = ({ children }) => { - const [counter, setCounter] = useState(null); - - useEffect(() => { - // Тут что-то делать для инициализации контекста - setCounter(initialContext); // Например - }, []); - - const value = useMemo(() => ({ counter, setCounter }), [counter]); // На самом деле, в случе нашего проекта это мало повлияет на производительность, но в каком-то туториале советовали так делать, поэтому почему бы и нет - - return ( - {children} - ); -}; - -export { CounterContext, CounterProvider }; diff --git a/pages/counter.tsx b/pages/counter.tsx deleted file mode 100644 index 4f3c30a..0000000 --- a/pages/counter.tsx +++ /dev/null @@ -1,15 +0,0 @@ -import React from "react"; -import { useCounter } from "hooks/counter"; - -const Counter = () => { - const { counter, increaseCounter } = useCounter(); - - return ( -
-

{counter}

- -
- ); -}; - -export default Counter \ No newline at end of file diff --git a/pages/index.tsx b/pages/index.tsx deleted file mode 100644 index 2d122a4..0000000 --- a/pages/index.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from "react"; -import Link from "next/link"; - -import ExampleComponent from "components/ExampleComponent"; -import PowerfulComponent from "components/PowerfulComponent"; - -export default function Home() { - return ( - <> - - - - Simplifyed counter - - - ); -} diff --git a/styles/exampleComponent.module.css b/styles/exampleComponent.module.css deleted file mode 100644 index 01bc332..0000000 --- a/styles/exampleComponent.module.css +++ /dev/null @@ -1,6 +0,0 @@ -/* Благодаря использованию css-modules можно использовать одни и те же названия классов - в разных компонентах и ничего нам за это не будет, ибо при сборке к ним добавятся хеши */ -.button { - background-color: red; - color: white; -} diff --git a/styles/globals.css b/styles/globals.css deleted file mode 100644 index e5e2dcc..0000000 --- a/styles/globals.css +++ /dev/null @@ -1,16 +0,0 @@ -html, -body { - padding: 0; - margin: 0; - font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, - Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; -} - -a { - color: inherit; - text-decoration: none; -} - -* { - box-sizing: border-box; -}