-
Notifications
You must be signed in to change notification settings - Fork 70
Kendiproject1 #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Kendiproject1 #38
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,140 @@ | ||
| .App { | ||
| * { | ||
| box-sizing: border-box; | ||
| margin: 0; | ||
| padding: 0; | ||
| font-family: "Trebuchet MS", "Lucida Sans Unicode", "Lucida Grande", | ||
| "Lucida Sans", Arial, sans-serif; | ||
| } | ||
|
|
||
| .todo-app { | ||
| display: flex; | ||
| flex-direction: column; | ||
| justify-content: start; | ||
| width: 520px; | ||
| min-height: 600px; | ||
| background: #161a2b; | ||
| text-align: center; | ||
| margin: 128px auto; | ||
| border-radius: 10px; | ||
| padding-bottom: 32px; | ||
| } | ||
|
|
||
| h1 { | ||
| margin: 32px 0; | ||
| color: #fff; | ||
| font-size: 24px; | ||
| } | ||
|
|
||
| .complete { | ||
| text-decoration: line-through; | ||
| opacity: 0.4; | ||
| } | ||
|
|
||
| .todo-form { | ||
| margin-bottom: 32px; | ||
| } | ||
|
|
||
| .App-logo { | ||
| height: 40vmin; | ||
| pointer-events: none; | ||
| .todo-input { | ||
| padding: 14px 32px 14px 16px; | ||
| border-radius: 4px 0 0 4px; | ||
| border: 2px solid #5d0cff; | ||
| outline: none; | ||
| max-width: 320px; | ||
| background: transparent; | ||
| color: #fff; | ||
| } | ||
|
|
||
| .App-header { | ||
| background-color: #282c34; | ||
| min-height: 100vh; | ||
| .todo-input::placeholder { | ||
| color: #e2e2e2; | ||
| } | ||
|
|
||
| .todo-button { | ||
| padding: 16px; | ||
| border: none; | ||
| border-radius: 0 4px 4px 0; | ||
| cursor: pointer; | ||
| outline: none; | ||
| background: linear-gradient( | ||
| 90deg, | ||
| rgba(93, 12, 255, 1) 0%, | ||
| rgba(155, 0, 250, 1) 100% | ||
| ); | ||
| color: #fff; | ||
| text-transform: capitalize; | ||
| } | ||
|
|
||
| .todo-input.edit { | ||
| border: 2px solid #149fff; | ||
| } | ||
|
|
||
| .todo-button.edit { | ||
| background: linear-gradient( | ||
| 90deg, | ||
| rgba(20, 159, 255, 1) 0%, | ||
| rgba(17, 122, 255, 1) 100% | ||
| ); | ||
| padding: 16px 22px; | ||
| } | ||
|
|
||
| .todo-container { | ||
| display: flex; | ||
| flex-direction: row; | ||
| position: relative; | ||
| } | ||
|
|
||
| .todo-row { | ||
| display: flex; | ||
| justify-content: space-between; | ||
| align-items: center; | ||
| margin: 4px auto; | ||
| color: #fff; | ||
| background: linear-gradient( | ||
| 90deg, | ||
| rgba(255, 118, 20, 1) 0%, | ||
| rgba(255, 84, 17, 1) 100% | ||
| ); | ||
|
|
||
| padding: 16px; | ||
| border-radius: 5px; | ||
| width: 90%; | ||
| } | ||
|
|
||
| .todo-row:nth-child(4n + 1) { | ||
| background: linear-gradient( | ||
| 90deg, | ||
| rgba(93, 12, 255, 1) 0%, | ||
| rgba(155, 0, 250, 1) 100% | ||
| ); | ||
| } | ||
|
|
||
| .todo-row:nth-child(4n + 2) { | ||
| background: linear-gradient( | ||
| 90deg, | ||
| rgba(255, 12, 241, 1) 0%, | ||
| rgba(250, 0, 135, 1) 100% | ||
| ); | ||
| } | ||
|
|
||
| .todo-row:nth-child(4n + 3) { | ||
| background: linear-gradient( | ||
| 90deg, | ||
| rgba(20, 159, 255, 1) 0%, | ||
| rgba(17, 122, 255, 1) 100% | ||
| ); | ||
| } | ||
|
|
||
| .icons { | ||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: center; | ||
| justify-content: center; | ||
| font-size: calc(10px + 2vmin); | ||
| color: white; | ||
| font-size: 24px; | ||
| cursor: pointer; | ||
| } | ||
|
|
||
| .delete-icon { | ||
| margin-right: 5px; | ||
| color: #fff; | ||
| } | ||
|
|
||
| .edit-icon { | ||
| color: #fff; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| import React, { useState } from "react"; | ||
| import TodoForm from "./TodoForm"; | ||
| import { RiCloseCircleLine } from "react-icons/ri"; | ||
| import { TiEdit } from "react-icons/ti"; | ||
|
|
||
| function Todo({ todos, completeTodo, removeTodo, updateTodo }) { | ||
| const [editMode, setEditMode] = useState(false); | ||
| const [edit, setEdit] = useState({ | ||
| id: null, | ||
| value: "", | ||
| }); | ||
|
|
||
| const submitUpdate = (value) => { | ||
| updateTodo(value.id, value); | ||
|
|
||
| setEdit({ | ||
| id: null, | ||
| value: "", | ||
| }); | ||
| }; | ||
| if (edit.id) { | ||
| return <TodoForm edit={edit} editMode={editMode} setEditMode={setEditMode} onSubmit={submitUpdate} />; | ||
| } | ||
| return todos.map((todo, index) => ( | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it is odd to render a list of todos in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the TodoList component I would do something like this: |
||
| <div | ||
| className={todo.isCpmplete ? "todo-row complete" : "todo-row"} | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have a typo here, I think this will not work |
||
| key={index} | ||
| > | ||
| <div key={todo.id} onClick={() => completeTodo(todo.id)}> | ||
| {todo.text} | ||
| </div> | ||
| <div className="icons"> | ||
| <RiCloseCircleLine | ||
| onClick={() => removeTodo(todo.id)} | ||
| className="delete - icon" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with the spacing in the className, this styling will probably not be applied properly |
||
| /> | ||
|
|
||
| <TiEdit | ||
| onClick={() => { | ||
| setEdit({ id: todo, value: todo.text }) | ||
| setEditMode(true); | ||
| }} | ||
| className="edit-icon" | ||
| /> | ||
| </div> | ||
| </div> | ||
| )); | ||
| } | ||
|
|
||
| export default Todo; | ||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,72 @@ | ||||||||||
| import React, { useState } from "react"; | ||||||||||
| import { Modal, Center } from "@mantine/core"; | ||||||||||
|
|
||||||||||
| function TodoForm(props) { | ||||||||||
| const [input, setInput] = useState(""); | ||||||||||
| const [update, setUpdate] = useState(props.edit ? props.edit.value : ""); | ||||||||||
|
|
||||||||||
| const handleChange = (e) => { | ||||||||||
| if (props.editMode) setUpdate(e.target.value) | ||||||||||
| else setInput(e.target.value); | ||||||||||
|
Comment on lines
+9
to
+10
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if you use return statements, the else is redundant here.
Suggested change
|
||||||||||
| }; | ||||||||||
|
|
||||||||||
| const handleSubmit = (e) => { | ||||||||||
| e.preventDefault(); | ||||||||||
|
|
||||||||||
| props.onSubmit({ | ||||||||||
| id: Math.floor(Math.random() * 10000), | ||||||||||
| text: input, | ||||||||||
| }); | ||||||||||
|
|
||||||||||
| // makes the to do invisible. | ||||||||||
| setInput(""); | ||||||||||
| }; | ||||||||||
|
|
||||||||||
| const handleUpdate = (e) => { | ||||||||||
| e.preventDefault(); | ||||||||||
|
|
||||||||||
| // makes the to do invisible. | ||||||||||
| setUpdate(""); | ||||||||||
| props.setEditMode(false); | ||||||||||
|
|
||||||||||
| props.onSubmit({ | ||||||||||
| id: props.edit.id, | ||||||||||
| text: update, | ||||||||||
| }); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| return ( | ||||||||||
| <> | ||||||||||
| <Modal opened={props.editMode} title={'Update Task'} size={'lg'} onClose={() => props.setEditMode(false)} centered> | ||||||||||
| <Center> | ||||||||||
| <input | ||||||||||
| type="text" | ||||||||||
| placeholder="update your item " | ||||||||||
| value={update} | ||||||||||
| name="text" | ||||||||||
| className="todo-input edit" | ||||||||||
| onChange={handleChange} | ||||||||||
| style={{ color: props.colorScheme === "dark" ? "white" : "black"}} | ||||||||||
| /> | ||||||||||
| <button className="todo-button edit" onClick={handleUpdate}>update</button> | ||||||||||
| </Center> | ||||||||||
| </Modal> | ||||||||||
| <form className="todo-form" onSubmit={handleSubmit}> | ||||||||||
| <div> | ||||||||||
| <input | ||||||||||
| type="text" | ||||||||||
| placeholder="Add a todo" | ||||||||||
| value={input} | ||||||||||
| name="text" | ||||||||||
| className="todo-input" | ||||||||||
| onChange={handleChange} | ||||||||||
| style={{ color: props.colorScheme === "dark" ? "white" : "black"}} | ||||||||||
| /> | ||||||||||
| <button className="todo-button">Add todo</button> | ||||||||||
| </div> | ||||||||||
| </form> | ||||||||||
| </> | ||||||||||
| ); | ||||||||||
| } | ||||||||||
|
|
||||||||||
| export default TodoForm; | ||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the README file is missing any content about your project. The planning documents are also missing