Create A TODO Application in React With Necessary Components and Deploy It Into Github.
Create A TODO Application in React With Necessary Components and Deploy It Into Github.
cd weather-app
In the project directory, install the necessary packages by executing the following command
npm install
We will use the Axios library to make HTTP requests to the OpenWeatherMap API.
{
"name": "todo-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
},
"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"
]
}
}
App.css
.App {
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
background-color: #f5f5f5;
}
.todo-container {
background-color: white;
padding: 2rem;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
width: 100%;
max-width: 500px;
}
h1 {
text-align: center;
color: #333;
margin-bottom: 2rem;
}
.todo-form {
display: flex;
gap: 1rem;
margin-bottom: 2rem;
}
.todo-input {
flex: 1;
padding: 0.5rem;
border: 1px solid #ddd;
border-radius: 4px;
font-size: 1rem;
}
.todo-button {
padding: 0.5rem 1rem;
background-color: #4CAF50;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 1rem;
}
.todo-button:hover {
background-color: #45a049;
}
.todo-list {
list-style: none;
padding: 0;
margin: 0;
}
.todo-item {
display: flex;
align-items: center;
gap: 1rem;
padding: 0.5rem;
border-bottom: 1px solid #eee;
}
.todo-item:last-child {
border-bottom: none;
}
.todo-item input[type="checkbox"] {
margin-right: 0.5rem;
}
.todo-item span {
flex: 1;
}
.delete-button {
padding: 0.25rem 0.5rem;
background-color: #ff4444;
color: white;
border: none;
border-radius: 4px;
cursor: pointer;
}
.delete-button:hover {
background-color: #cc0000; }
App.js
function App() {
const [todos, setTodos] = useState([]);
return (
<div className="App">
<div className="todo-container">
<h1>Todo List</h1>
<TodoForm onSubmit={addTodo} />
<TodoList
todos={todos}
onToggle={toggleTodo}
onDelete={deleteTodo}
/>
</div>
</div>
);
}
index.css
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
code {
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
monospace;
}
index.js
Components/TodoForm.js
return (
<form onSubmit={handleSubmit} className="todo-form">
<input
type="text"
value={text}
onChange={(e) => setText(e.target.value)}
placeholder="Add a new todo..."
className="todo-input"
/>
<button type="submit" className="todo-button">
Add
</button>
</form>
);
}
export default TodoForm;
Components/TodoList.js
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Todo List Application created using React"
/>
<title>Todo List App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
Uploading a Project to GitHub Using Git
Introduction
Git is a powerful version control system that allows developers to track changes, collaborate, and
manage project history efficiently. This guide provides step-by-step instructions on how to
upload a project to GitHub using Git.
Prerequisites
Before proceeding, ensure you have the following:
Conclusion
Your project is now successfully uploaded to GitHub. You can view it by navigating to your
repository URL in a web browser. Git allows you to track changes, collaborate, and manage
project history efficiently.
Next Steps
Clone your repository on another machine: git clone
https://github.com/yourusername/repository.git
Make and push changes:
git add .
git commit -m "Updated feature"
git push origin main
Pull the latest changes from GitHub:
git pull origin main