homeman-deno/components/TodoList.tsx

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2024-01-07 02:24:36 -06:00
import { Todo, UserWithTodos } from '@homeman/models.ts'
2024-01-07 10:55:18 -06:00
import { Button } from '@homeman/components/Button.tsx'
2024-01-06 23:53:44 -06:00
export interface Props {
2024-01-07 02:24:36 -06:00
user: UserWithTodos
2024-01-06 23:53:44 -06:00
}
2024-01-07 10:55:18 -06:00
export function TodoList(
{ user: { avatarUrl, assignedTodos, name, color } }: Props,
) {
const todoItem = (
2024-01-07 16:42:03 -06:00
{ className, description, hideDone }: Pick<Todo, 'description'> & {
className?: string
hideDone?: boolean
2024-01-07 10:55:18 -06:00
},
) => (
<li
style={`border-color: #${color}`}
class={`${
2024-01-07 16:42:03 -06:00
className || ''
2024-01-07 10:55:18 -06:00
} border-l-4 p-4 rounded drop-shadow-lg bg-white dark:bg-stone-900 flex flex-col`}
>
<span class='text-xl'>{description}</span>
2024-01-07 16:42:03 -06:00
{hideDone ? '' : <Button class='mt-2'>Done</Button>}
2024-01-07 10:55:18 -06:00
</li>
2024-01-07 02:24:36 -06:00
)
2024-01-06 23:53:44 -06:00
return (
2024-01-07 10:55:18 -06:00
<div class='p-2 w-1/4 min-w-[15rem] relative flex flex-col grow-0'>
<img
2024-01-07 16:21:14 -06:00
class='rounded-full w-[15rem] h-[15rem] mb-2 object-cover'
2024-01-07 10:55:18 -06:00
src={avatarUrl != null ? avatarUrl : 'https://placehold.co/512x512'}
title={`${name}'s avatar`}
/>
2024-01-07 16:37:45 -06:00
<span style={`color: #${color};`} class='font-semibold text-center'>
2024-01-07 02:24:36 -06:00
{name}
</span>
<button class='mt-4 mb-4 text-left w-full px-2 py-1 rounded-lg border-[1px] text-stone-500 border-stone-500 opacity-50 hover:opacity-100'>
+ New
</button>
2024-01-07 10:55:18 -06:00
<ul class='flex flex-col gap-y-4'>
2024-01-07 02:24:36 -06:00
{assignedTodos.length < 1
2024-01-07 16:42:03 -06:00
? todoItem({
description: 'All clear! 🎉',
className: 'text-center',
hideDone: true,
})
2024-01-07 02:24:36 -06:00
: assignedTodos.map(todoItem)}
</ul>
2024-01-06 23:53:44 -06:00
</div>
)
}