feat: task status change

This commit is contained in:
2025-04-23 16:45:06 +03:00
parent b091e8d20d
commit 9841da8b88
2 changed files with 31 additions and 16 deletions

View File

@@ -1,4 +1,5 @@
import { FunctionComponent } from "preact"; import { FunctionComponent } from "preact";
import { MouseEventHandler } from "preact/compat";
import { tv } from "tailwind-variants"; import { tv } from "tailwind-variants";
import classes from "./task.module.scss"; import classes from "./task.module.scss";
@@ -6,10 +7,11 @@ interface TaskProps {
name: string; name: string;
checked?: boolean; checked?: boolean;
onClick?: () => void; onClick?: () => void;
onMarkClick?: MouseEventHandler<HTMLParagraphElement>;
} }
const taskStyle = tv({ const taskStyle = tv({
base: "flex aspect-square h-full flex-col items-center justify-center rounded-full border", base: "hover:scale-[1.1]active:scale-[1.1] flex aspect-square h-full flex-col items-center justify-center rounded-full border transition-[scale] duration-100 ease-in-out select-none",
variants: { variants: {
checked: { checked: {
true: "bg-black", true: "bg-black",
@@ -28,12 +30,18 @@ const markStyle = tv({
}, },
}); });
const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {} }: TaskProps) => { const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = () => {}, onMarkClick = () => {} }) => {
return ( return (
// Временное действие для тестирования // Временное действие для тестирования
<div class="w-[95%]"> <div class="w-[95%]">
<div class={classes.task} onClick={onClick}> <div class={classes.task} onClick={onClick}>
<div class={taskStyle({ checked })}> <div
class={taskStyle({ checked })}
onClick={(e) => {
e.stopPropagation();
onMarkClick(e);
}}
>
<p class={markStyle({ checked })}></p> <p class={markStyle({ checked })}></p>
</div> </div>
{name} {name}
@@ -42,4 +50,6 @@ const Task: FunctionComponent<TaskProps> = ({ name, checked = false, onClick = (
); );
}; };
Task.displayName = "AHTask";
export default Task; export default Task;

View File

@@ -238,8 +238,8 @@ const ProfileTasks: FunctionComponent = () => {
handleSubmit((data) => saveTask({ ...data, id: tasks.length + 1 }))(); handleSubmit((data) => saveTask({ ...data, id: tasks.length + 1 }))();
}} }}
> >
<div class="flex w-full flex-row items-start justify-between"> <div class="flex w-full flex-1 flex-row items-start justify-between">
<div class="me-4 flex flex-1 flex-col gap-1"> <div class="me-4 flex h-full flex-1 flex-col gap-1">
<input <input
class="text-2xl outline-0" class="text-2xl outline-0"
maxLength={20} maxLength={20}
@@ -247,7 +247,7 @@ const ProfileTasks: FunctionComponent = () => {
{...register("name", { required: "Заполните название" })} {...register("name", { required: "Заполните название" })}
/> />
<textarea <textarea
class="h-[5rem] w-full resize-none outline-0" class="mb-10 w-full flex-1 resize-none outline-0"
placeholder="Описание" placeholder="Описание"
maxLength={200} maxLength={200}
{...register("description")} {...register("description")}
@@ -260,6 +260,7 @@ const ProfileTasks: FunctionComponent = () => {
/> />
<input type="checkbox" checked={false} hidden {...register("checked")} /> <input type="checkbox" checked={false} hidden {...register("checked")} />
</div> </div>
<div class="flex flex-row gap-3 self-start">
<CalendarDaysIcon <CalendarDaysIcon
class="size-10 cursor-pointer" class="size-10 cursor-pointer"
onClick={() => { onClick={() => {
@@ -269,6 +270,7 @@ const ProfileTasks: FunctionComponent = () => {
/> />
<BookmarkIcon class="ms-4 size-10 cursor-pointer" /> <BookmarkIcon class="ms-4 size-10 cursor-pointer" />
</div> </div>
</div>
{errors.name && <p class="text-red-500">{errors.name.message}</p>} {errors.name && <p class="text-red-500">{errors.name.message}</p>}
{errors.date && <p class="text-red-500">{errors.date.message}</p>} {errors.date && <p class="text-red-500">{errors.date.message}</p>}
<div className="mb-8 flex h-16 flex-col items-center gap-6 self-center md:mb-0 md:flex-row md:self-start"> <div className="mb-8 flex h-16 flex-col items-center gap-6 self-center md:mb-0 md:flex-row md:self-start">
@@ -304,10 +306,13 @@ const ProfileTasks: FunctionComponent = () => {
setEditContent(task); setEditContent(task);
setCalendarDate(task.date); setCalendarDate(task.date);
}} }}
onMarkClick={() => {
setTasks(tasks.map((t) => (t.id === task.id ? { ...t, checked: !t.checked } : t)));
}}
/> />
))} ))}
</div> </div>
<div class="group fixed right-[22rem] bottom-4 hidden flex-row items-center justify-start space-x-3 overflow-x-hidden py-2 md:flex"> <div class="group fixed right-1 bottom-16 flex flex-row items-center justify-start space-x-3 overflow-x-hidden py-2 md:right-[22rem] md:bottom-4">
<div <div
class="flex aspect-square h-20 cursor-pointer items-center justify-center rounded-full bg-[rgb(251,194,199,0.53)] text-9xl text-white shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] transition-all duration-300 ease-out group-hover:ml-[12rem] hover:bg-[rgb(251,194,199,0.7)]" class="flex aspect-square h-20 cursor-pointer items-center justify-center rounded-full bg-[rgb(251,194,199,0.53)] text-9xl text-white shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] transition-all duration-300 ease-out group-hover:ml-[12rem] hover:bg-[rgb(251,194,199,0.7)]"
onClick={() => { onClick={() => {
@@ -317,7 +322,7 @@ const ProfileTasks: FunctionComponent = () => {
> >
<PlusIcon /> <PlusIcon />
</div> </div>
<div class="absolute left-0 my-auto flex flex-row space-x-3 opacity-0 transition-opacity duration-100 group-hover:opacity-100"> <div class="absolute left-0 my-auto hidden flex-row space-x-3 opacity-0 transition-opacity duration-100 group-hover:opacity-100 md:flex">
<div class="pointer-events-none flex aspect-square h-20 cursor-pointer flex-col items-center justify-center rounded-full bg-[rgba(206,232,251,0.7)] text-xl text-gray-600 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] group-hover:pointer-events-auto hover:bg-[rgba(206,232,251,0.9)]"> <div class="pointer-events-none flex aspect-square h-20 cursor-pointer flex-col items-center justify-center rounded-full bg-[rgba(206,232,251,0.7)] text-xl text-gray-600 shadow-[0px_4px_4px_0px_rgba(0,0,0,0.25)] group-hover:pointer-events-auto hover:bg-[rgba(206,232,251,0.9)]">
<MagnifyingGlassIcon class="size-12" /> <MagnifyingGlassIcon class="size-12" />
</div> </div>