| 1 |
import { CardContent } from '@assist/components/dashboard/CardContent'; |
| 2 |
import { CardsTitle } from '@assist/components/dashboard/CardsTitle'; |
| 3 |
import { useTasksStore } from '@assist/state/tasks'; |
| 4 |
import { Bullet } from '@assist/svg'; |
| 5 |
import { Disclosure } from '@headlessui/react'; |
| 6 |
import { check, chevronUp, Icon } from '@wordpress/icons'; |
| 7 |
import classNames from 'classnames'; |
| 8 |
|
| 9 |
export const MobileCards = ({ className, totalCompleted, tasks }) => { |
| 10 |
const { isCompleted } = useTasksStore(); |
| 11 |
|
| 12 |
return ( |
| 13 |
<div |
| 14 |
className={classNames( |
| 15 |
className, |
| 16 |
'mb-6 h-full w-full overflow-auto rounded-sm border border-gray-300 bg-white', |
| 17 |
)} |
| 18 |
> |
| 19 |
<CardsTitle totalCompleted={totalCompleted} total={tasks.length} /> |
| 20 |
|
| 21 |
{tasks.map((task) => { |
| 22 |
const isCompletedTask = isCompleted(task.slug); |
| 23 |
return ( |
| 24 |
<Disclosure key={task.slug}> |
| 25 |
{({ open }) => ( |
| 26 |
<> |
| 27 |
<Disclosure.Button |
| 28 |
as="div" |
| 29 |
className={classNames( |
| 30 |
'flex w-full items-center border-b text-base', |
| 31 |
{ |
| 32 |
'border-transparent font-semibold': open, |
| 33 |
'border-gray-400': !open, |
| 34 |
}, |
| 35 |
)} |
| 36 |
> |
| 37 |
<div className="group flex w-full items-center justify-between px-5 py-4 hover:cursor-pointer hover:bg-gray-100 md:border md:border-gray-100 lg:px-6"> |
| 38 |
<div className="flex w-full items-center space-x-2"> |
| 39 |
<Icon |
| 40 |
icon={isCompletedTask ? check : Bullet} |
| 41 |
size={isCompletedTask ? 24 : 12} |
| 42 |
className={classNames('flex-shrink-0', { |
| 43 |
'fill-current text-design-main': open, |
| 44 |
'mx-2 text-center text-gray-400': |
| 45 |
!isCompletedTask && !open, |
| 46 |
'mx-2': !isCompletedTask && open, |
| 47 |
})} |
| 48 |
/> |
| 49 |
{task?.sidebarTitle ?? task.title} |
| 50 |
</div> |
| 51 |
<div className="md:hidden"> |
| 52 |
<Icon |
| 53 |
icon={chevronUp} |
| 54 |
className={classNames( |
| 55 |
'h-5 w-5 text-purple-500 md:hidden', |
| 56 |
{ |
| 57 |
'rotate-180 transform': open, |
| 58 |
}, |
| 59 |
)} |
| 60 |
/> |
| 61 |
</div> |
| 62 |
</div> |
| 63 |
</Disclosure.Button> |
| 64 |
|
| 65 |
<Disclosure.Panel className="border-b border-gray-400"> |
| 66 |
<CardContent task={task} /> |
| 67 |
</Disclosure.Panel> |
| 68 |
</> |
| 69 |
)} |
| 70 |
</Disclosure> |
| 71 |
); |
| 72 |
})} |
| 73 |
</div> |
| 74 |
); |
| 75 |
}; |
| 76 |
|