From 0988f8e27699c73aeaea3b51beaea1ec1d5d32a9 Mon Sep 17 00:00:00 2001 From: PluckyPrecious Date: Fri, 28 May 2021 00:17:09 +0100 Subject: [PATCH 1/2] To-Do React App create an app that allows items --- .../React/todo-App/.gitignore | 23 ++ .../React/todo-App/README.md | 70 ++++++ .../React/todo-App/public/index.html | 18 ++ .../React/todo-App/public/manifest.json | 8 + .../React/todo-App/src/App.js | 120 +++++++++ .../React/todo-App/src/App.test.js | 8 + .../React/todo-App/src/components/Button.js | 23 ++ .../todo-App/src/components/ClearButton.js | 18 ++ .../React/todo-App/src/components/Form.js | 36 +++ .../React/todo-App/src/components/Todo.js | 18 ++ .../React/todo-App/src/index.css | 236 ++++++++++++++++++ .../React/todo-App/src/index.js | 15 ++ 12 files changed, 593 insertions(+) create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/.gitignore create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/README.md create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/public/index.html create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/public/manifest.json create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/App.js create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/App.test.js create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Button.js create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/ClearButton.js create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Form.js create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Todo.js create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.css create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.js diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/.gitignore b/submissions/KelechiPreciousNwachukwu/React/todo-App/.gitignore new file mode 100644 index 000000000..4d29575de --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/.gitignore @@ -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* diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/README.md b/submissions/KelechiPreciousNwachukwu/React/todo-App/README.md new file mode 100644 index 000000000..0c83cde2c --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/README.md @@ -0,0 +1,70 @@ +# Getting Started with Create React App + +This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). + +## Available Scripts + +In the project directory, you can run: + +### `npm start` + +Runs the app in the development mode.\ +Open [http://localhost:3000](http://localhost:3000) to view it in the browser. + +The page will reload if you make edits.\ +You will also see any lint errors in the console. + +### `npm test` + +Launches the test runner in the interactive watch mode.\ +See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. + +### `npm run build` + +Builds the app for production to the `build` folder.\ +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.\ +Your app is ready to be deployed! + +See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. + +### `npm run eject` + +**Note: this is a one-way operation. Once you `eject`, you can’t go back!** + +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. + +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. + +## Learn More + +You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). + +To learn React, check out the [React documentation](https://reactjs.org/). + +### Code Splitting + +This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) + +### Analyzing the Bundle Size + +This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) + +### Making a Progressive Web App + +This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) + +### Advanced Configuration + +This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) + +### Deployment + +This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) + +### `npm run build` fails to minify + +This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/public/index.html b/submissions/KelechiPreciousNwachukwu/React/todo-App/public/index.html new file mode 100644 index 000000000..f53314980 --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/public/index.html @@ -0,0 +1,18 @@ + + + + + + + + + Hoopla App + + + +
+ + diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/public/manifest.json b/submissions/KelechiPreciousNwachukwu/React/todo-App/public/manifest.json new file mode 100644 index 000000000..8af73c478 --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/public/manifest.json @@ -0,0 +1,8 @@ +{ + "short_name": "ToDo App", + "name": "Hoopla App", + "start_url": ".", + "display": "standalone", + "theme_color": "#316879, #f47a60, #7fe7dc", + "background_color": "#ced7d8" +} diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/src/App.js b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/App.js new file mode 100644 index 000000000..b33b511cf --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/App.js @@ -0,0 +1,120 @@ +import React, { Component } from 'react'; +import { nanoid } from 'nanoid'; +import Todo from './components/Todo'; +import Button from './components/Button'; +import Form from './components/Form'; +import ClearButton from './components/ClearButton'; + +const filter_functions = { + All: () => true, + Active: task => task.status === 'active', + Completed: task => task.status === 'completed' +}; + +const filter_names = Object.keys(filter_functions); + +class App extends Component { + state = { + tasks: this.props.tasks, + filter: 'All' + } + + render() { + const tasks = this.state.tasks; + + const setFilter = (name) => { + this.setState({ + filter: name + }) + }; + + const toggleCompleted = (id) => { + const updatedTasks = tasks.map(task => { + if (id === task.id) { + const theStatus = task.status === 'active' ? 'completed' : 'active'; + return { ...task, status: theStatus } + } + + return task; + } ) + this.setState({ + tasks: updatedTasks + }) + }; + + const tasklist = tasks + .filter(filter_functions[this.state.filter]) + .map(task => { + return ( + + ) + }); + + const filterList = filter_names.map(name => { + return ( + + ) +} + +export default Button; \ No newline at end of file diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/ClearButton.js b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/ClearButton.js new file mode 100644 index 000000000..e113cd24e --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/ClearButton.js @@ -0,0 +1,18 @@ +import React from 'react'; + +const ClearButton = (props) => { + return ( +
+ +
+ ); +}; + +export default ClearButton; \ No newline at end of file diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Form.js b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Form.js new file mode 100644 index 000000000..ac27833d1 --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Form.js @@ -0,0 +1,36 @@ +import React, { Component } from 'react'; + +class Form extends Component { + state = { + inputText: '' + } + + handleSubmit = (e) => { + e.preventDefault(); + + if (this.state.inputText !== '') { + this.props.addTask(this.state.inputText); + this.setState({ + inputText: '' + }) + } + } + + render() { + return ( + + this.setState({ inputText: e.target.value})} /> + + + ) + } +} + +export default Form; \ No newline at end of file diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Todo.js b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Todo.js new file mode 100644 index 000000000..64426ebba --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/components/Todo.js @@ -0,0 +1,18 @@ +import React from 'react'; + +const Todo = (props) => { + return ( +
  • +
    + + props.toggleStatus(props.id) } + className = {props.status} /> +
    +
  • + ) +} + +export default Todo; \ No newline at end of file diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.css b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.css new file mode 100644 index 000000000..7aad4ab92 --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.css @@ -0,0 +1,236 @@ +*, +*::before, +*::after { + box-sizing: border-box; +} + +html { + font-family: Arial, Helvetica, sans-serif; +} + +body { + width: 100%; + height: 100vh; + margin: 0; + padding: 0; + background: linear-gradient(to bottom, #316879 220px, #ced7d8 220px); +} + +h1 { + color: #FFF; + font-weight: 100; + padding: 30px 0; +} + +h2 { + font-size: 0.8rem; +} + +h2.list-number { + color: #316879; +} + +form { + width: 100%; + display: grid; + grid-template-columns: 84% 14%; + column-gap: 5px; + margin-bottom: 20px; +} + +ul { + list-style-type: none; + padding: 0 10px; +} + +form input { + padding: 12px 10px; +} + +.todoapp { + width: 50%; + margin: 0 auto; + padding-bottom: 20px; +} + +.input-todo, .btn-submit { + border-radius: 7px; + border: none; +} + +.btn-submit { + background-color: #7fe7dc; + font-size: 30px; +} + +.todo-container { + width: 100%; + border-radius: 15px; + box-shadow: 0px 2px 1px 1px #acbbbd; +} + +.todo-list { + background-color: #f47a60; + border-radius: 10px 10px 0 0; + padding: 20px 0 5px 0; +} + +.todo-item { + display: flex; + justify-content: space-between; + background-color: #FFF; + margin: 10px 30px; + padding: 15px; + border-radius: 10px; + font-size: 0.9rem; +} + +.todo-extras { + display: flex; + justify-content: space-between; + align-items: center; + border-radius: 0 0 10px 10px; + padding: 10px; +} + +.btn { + border: none; + background: none; + font-size: 0.8rem; +} + +button.btn.all { + color: #0000ff; +} + +.checkbox { + position: absolute; + top: 1.2rem; + left: 22rem; +} + +[type='checkbox']:not(:checked):before { + content: ''; + position: absolute; + width: 1em; + height: 1em; + border: 1px solid #fc0000; + background: #fff; + border-radius: 0.2em; +} + +[type='checkbox']:checked::after { + content: '✅'; + position: absolute; + color: #3db35e; + background: #fff; +} + +.clear { + color: #fc0000; +} + +.active { + color: #f42337; +} + +label.active { + color:#316879; +} + +.completed-button { + color: #3db35e; +} + +.completed { + color: #3db35e; + text-decoration: line-through; +} + +.todo-extras2 { + display: none; +} + +@media screen and (max-width: 900px) { + h2, .btn { + font-size: 0.7rem; + } +} + +@media screen and (max-width: 768px) { + body { + background: linear-gradient(to #316879 200px, #ced7d8 200px); + } + + .show { + display: flex; + align-items: center; + justify-content: space-between; + padding: 5px 30px; + } + + .todo-extras2 h2, .todo-extras2 .btn { + font-size: 0.8rem; + } + + .todo-extras .list-number, .todo-extras .clear { + display: none; + } + + .todo-extras { + display: block; + text-align: center; + } + + .filters .btn { + font-size: 0.8rem; + } +} + +@media screen and (max-width: 450px) { + .todoapp { + width: 78%; + } + + .todo-list { + border-radius: 0; + } + + form { + display: grid; + grid-template-columns: 84% 14%; + column-gap: 5px; + margin-bottom: 20px; + margin-top: 38px; + } + + .filters .btn, .todo-extras2 h2, .todo-extras2 .btn { + font-size: 0.7rem; + } + + button.btn-submit { + padding: 5px; + } + + .todo-container { + margin: 0; + border-radius: 0px; + } + + .todo-extras { + max-width: auto; + margin-bottom: 15px; + border-radius: 0 0 10px 10px; + padding: 10px; + } + + .todo-item { + margin: auto; + align-items: center; + margin-bottom: 15px; + } + + ul { + padding-top: 0 10px; + } +} \ No newline at end of file diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.js b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.js new file mode 100644 index 000000000..d6ed4c570 --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/src/index.js @@ -0,0 +1,15 @@ +import React from 'react'; +import ReactDOM from 'react-dom'; +import './index.css'; +import App from './App'; + +const TASKS = [ + +]; + +ReactDOM.render( + + + , + document.getElementById('root') +); \ No newline at end of file From 3449d73e0891a4d157a7997cb54b4d8e79f1506a Mon Sep 17 00:00:00 2001 From: PluckyPrecious Date: Tue, 1 Jun 2021 06:51:37 +0100 Subject: [PATCH 2/2] Create package.json --- .../React/todo-App/package.json | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 submissions/KelechiPreciousNwachukwu/React/todo-App/package.json diff --git a/submissions/KelechiPreciousNwachukwu/React/todo-App/package.json b/submissions/KelechiPreciousNwachukwu/React/todo-App/package.json new file mode 100644 index 000000000..4784491a3 --- /dev/null +++ b/submissions/KelechiPreciousNwachukwu/React/todo-App/package.json @@ -0,0 +1,38 @@ +{ + "name": "hoopla-app", + "version": "0.1.0", + "private": true, + "dependencies": { + "@testing-library/jest-dom": "^5.12.0", + "@testing-library/react": "^11.2.7", + "@testing-library/user-event": "^12.8.3", + "react": "^17.0.2", + "react-dom": "^17.0.2", + "react-scripts": "4.0.3", + "web-vitals": "^1.1.2" + }, + "scripts": { + "start": "react-scripts start", + "build": "react-scripts build", + "test": "react-scripts test", + "eject": "react-scripts eject" + }, + "eslintConfig": { + "extends": [ + "react-app", + "react-app/jest" + ] + }, + "browserslist": { + "production": [ + ">0.2%", + "not dead", + "not op_mini all" + ], + "development": [ + "last 1 chrome version", + "last 1 firefox version", + "last 1 safari version" + ] + } +}