mirror of
https://github.com/LucasVbr/todo-list.git
synced 2026-12-05 17:30:49 +00:00
Install clsx and heroicons
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import {FormEvent, useState} from 'react';
|
||||
import {useDispatch} from 'react-redux';
|
||||
import {addTodo} from '../../features/todo/todoSlice.ts';
|
||||
import {PlusIcon} from '@heroicons/react/24/outline';
|
||||
|
||||
export default function TodoAddItemForm() {
|
||||
const [name, setName] = useState('');
|
||||
@@ -17,20 +18,12 @@ export default function TodoAddItemForm() {
|
||||
<form onSubmit={handleSubmit} className={'TodoAddItemForm'}>
|
||||
<div className={'form-control'}>
|
||||
<div className={'input-group'}>
|
||||
<input type={'text'} value={name} placeholder={'Type here your task...'}
|
||||
<input type={'text'} value={name}
|
||||
placeholder={'Type here your task...'}
|
||||
className={'input border-primary w-full'}
|
||||
onChange={evt => setName(evt.target.value)}
|
||||
/>
|
||||
onChange={evt => setName(evt.target.value)}/>
|
||||
<button type={'submit'} className={'btn btn-square btn-primary'}>
|
||||
|
||||
{/*Plus icon*/}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" className="h-6 w-6"
|
||||
fill="none"
|
||||
viewBox="0 0 24 24" stroke="currentColor" strokeWidth="2">
|
||||
<path strokeLinecap="round" strokeLinejoin="round"
|
||||
d="M12 4v16m8-8H4"/>
|
||||
</svg>
|
||||
|
||||
<PlusIcon className={"h-6 w-6"}/>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -6,7 +6,11 @@ import TodoState from '../../models/TodoState.ts';
|
||||
export default function TodoCardFooter() {
|
||||
|
||||
const dispatch = useDispatch();
|
||||
const selectedTodosCount: number = useSelector((state: RootState) => state.todo.filter((todo: TodoState) => !todo.checked).length);
|
||||
const selectedTodosCount: number = useSelector(
|
||||
(state: RootState) => state.todo.filter(
|
||||
(todo: TodoState) => !todo.checked
|
||||
).length
|
||||
);
|
||||
|
||||
const handleDelete = () => dispatch(deleteSelectedTodos());
|
||||
|
||||
|
||||
@@ -14,7 +14,8 @@ export default function TodoItem({todo}: Props) {
|
||||
|
||||
return (
|
||||
<label className={clsx('TodoItem',
|
||||
'border-[1px] border-base-300 shadow rounded-lg p-4 w-full cursor-pointer',
|
||||
'w-full p-4 rounded-lg cursor-pointer',
|
||||
'border-[1px] border-base-300 shadow',
|
||||
'flex items-center justify-between gap-5')}>
|
||||
<span className={"break-all"}>{todo.name}</span>
|
||||
<input type={'checkbox'} onChange={handleCheck} checked={todo.checked}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import TodoItem from './TodoItem.tsx';
|
||||
import type TodoState from '../../models/TodoState.ts';
|
||||
import clsx from 'clsx';
|
||||
|
||||
type Props = {
|
||||
todos: TodoState[]
|
||||
@@ -7,7 +8,7 @@ type Props = {
|
||||
|
||||
export default function TodoItemList({todos}: Props) {
|
||||
return (
|
||||
<div className={'TodoItemList w-full flex flex-col gap-2'}>
|
||||
<div className={clsx('TodoItemList', 'w-full flex flex-col gap-2')}>
|
||||
{todos.map((todo: TodoState, index) => <TodoItem todo={todo} key={index}/>)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user