2021-09-06 10:35:40 -07:00
|
|
|
import { Disclosure } from '@headlessui/react'
|
|
|
|
import { ChevronDownIcon } from '@heroicons/react/outline'
|
|
|
|
|
2021-09-03 05:11:21 -07:00
|
|
|
export const Table = ({ children }) => (
|
|
|
|
<table className="min-w-full divide-y divide-th-bkg-2">{children}</table>
|
|
|
|
)
|
|
|
|
|
|
|
|
export const TrHead = ({ children }) => (
|
|
|
|
<tr className="text-th-fgd-3 text-xs">{children}</tr>
|
|
|
|
)
|
|
|
|
|
|
|
|
export const Th = ({ children }) => (
|
2021-09-06 10:35:40 -07:00
|
|
|
<th className="px-6 pb-2 text-left font-normal" scope="col">
|
2021-09-03 05:11:21 -07:00
|
|
|
{children}
|
|
|
|
</th>
|
|
|
|
)
|
|
|
|
|
2021-09-06 04:51:18 -07:00
|
|
|
export const TrBody = ({ children, index }) => (
|
2021-09-03 05:11:21 -07:00
|
|
|
<tr
|
|
|
|
className={`border-b border-th-bkg-3
|
2021-09-05 23:22:30 -07:00
|
|
|
${
|
|
|
|
index % 2 === 0
|
|
|
|
? `bg-[rgba(255,255,255,0.03)]`
|
|
|
|
: `bg-[rgba(255,255,255,0.07)]`
|
|
|
|
}
|
2021-09-03 05:11:21 -07:00
|
|
|
`}
|
|
|
|
>
|
|
|
|
{children}
|
|
|
|
</tr>
|
|
|
|
)
|
|
|
|
|
|
|
|
export const Td = ({ children }) => (
|
|
|
|
<td className="px-6 py-3.5 whitespace-nowrap text-sm text-th-fgd-1">
|
|
|
|
{children}
|
|
|
|
</td>
|
|
|
|
)
|
2021-09-06 10:35:40 -07:00
|
|
|
|
|
|
|
type ExpandableRowProps = {
|
|
|
|
buttonTemplate: React.ReactNode
|
|
|
|
index: number
|
|
|
|
panelTemplate: React.ReactNode
|
2021-09-19 17:36:02 -07:00
|
|
|
rounded?: boolean
|
2021-09-06 10:35:40 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
export const ExpandableRow = ({
|
|
|
|
buttonTemplate,
|
|
|
|
index,
|
|
|
|
panelTemplate,
|
2021-09-19 17:36:02 -07:00
|
|
|
rounded,
|
2021-09-06 10:35:40 -07:00
|
|
|
}: ExpandableRowProps) => {
|
|
|
|
return (
|
|
|
|
<Disclosure>
|
|
|
|
{({ open }) => (
|
|
|
|
<>
|
|
|
|
<Disclosure.Button
|
|
|
|
className={`${
|
2021-09-19 17:36:02 -07:00
|
|
|
index % 2 === 0 ? `bg-th-bkg-3` : `bg-th-bkg-4`
|
|
|
|
} default-transition font-normal p-4 text-th-fgd-1 w-full hover:filter hover:brightness-90 focus:outline-none ${
|
|
|
|
rounded
|
|
|
|
? open
|
|
|
|
? 'rounded-b-none'
|
|
|
|
: 'rounded-md'
|
|
|
|
: 'rounded-none'
|
|
|
|
}`}
|
2021-09-06 10:35:40 -07:00
|
|
|
>
|
2021-09-09 06:14:20 -07:00
|
|
|
<div className="grid grid-cols-12 grid-rows-1">
|
2021-09-06 10:35:40 -07:00
|
|
|
{buttonTemplate}
|
|
|
|
<div className="flex items-center justify-end">
|
|
|
|
<ChevronDownIcon
|
|
|
|
className={`${
|
|
|
|
open ? 'transform rotate-180' : 'transform rotate-360'
|
|
|
|
} default-transition h-5 flex-shrink-0 w-5 text-th-primary`}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</Disclosure.Button>
|
|
|
|
<Disclosure.Panel
|
|
|
|
className={`${
|
|
|
|
index % 2 === 0
|
|
|
|
? `bg-[rgba(255,255,255,0.03)]`
|
|
|
|
: `bg-[rgba(255,255,255,0.07)]`
|
2021-09-19 17:36:02 -07:00
|
|
|
} px-4 ${
|
|
|
|
rounded
|
|
|
|
? open
|
|
|
|
? 'rounded-b-md'
|
|
|
|
: 'rounded-none'
|
|
|
|
: 'rounded-none'
|
|
|
|
}`}
|
2021-09-06 10:35:40 -07:00
|
|
|
>
|
2021-09-19 17:36:02 -07:00
|
|
|
<div className="grid grid-cols-2 grid-rows-1 gap-4 py-4">
|
2021-09-06 10:35:40 -07:00
|
|
|
{panelTemplate}
|
|
|
|
</div>
|
|
|
|
</Disclosure.Panel>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</Disclosure>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
type RowProps = {
|
|
|
|
children: React.ReactNode
|
|
|
|
index: number
|
|
|
|
}
|
|
|
|
|
|
|
|
export const Row = ({ children, index }: RowProps) => {
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
className={`${
|
|
|
|
index % 2 === 0
|
|
|
|
? `bg-[rgba(255,255,255,0.03)]`
|
|
|
|
: `bg-[rgba(255,255,255,0.07)]`
|
|
|
|
} default-transition font-normal p-4 rounded-none text-th-fgd-1 w-full`}
|
|
|
|
>
|
|
|
|
<div className="grid grid-cols-12 grid-rows-1 gap-4">{children}</div>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|