homeman-deno/components/TodoList.tsx

47 lines
1.3 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 = (
{ classList, description }: Pick<Todo, 'description'> & {
classList?: string
},
) => (
<li
style={`border-color: #${color}`}
class={`${
classList || ''
} border-l-4 p-4 rounded drop-shadow-lg bg-white dark:bg-stone-900 flex flex-col`}
>
<span class='text-xl'>{description}</span>
<Button class='mt-2'>Done</Button>
</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
class='rounded-full w-full mb-2'
src={avatarUrl != null ? avatarUrl : 'https://placehold.co/512x512'}
title={`${name}'s avatar`}
/>
2024-01-07 02:24:36 -06:00
<span class='text-sky-800 dark:text-sky-200 font-semibold text-center'>
{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 10:55:18 -06:00
? todoItem({ description: 'All clear! 🎉', classList: 'text-center' })
2024-01-07 02:24:36 -06:00
: assignedTodos.map(todoItem)}
</ul>
2024-01-06 23:53:44 -06:00
</div>
)
}