Skip to content

Commit

Permalink
Indent relatives in the results list
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardofano committed Aug 20, 2023
1 parent 4fdfae3 commit 3bfb3ea
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions components/Results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,20 @@ function Results({ inheritance, setEditing }: ResultsProps) {
const inheritanceMoney = currencyFormatter.format(inheritanceValue * intMoney)

const relation = categoryRelation[relative.category]
const depth = countDepth(list, relativeId)

return (
<tr key={relativeId} className="border-t">
<td className="px-4 py-2">
<p className="font-medium text-gray-800">{relative.name}</p>
<p className="text-sm text-gray-600 md:text-base">
{relation} {list[relative.root].name}
</p>
<td className="flex p-0">
<div className="bg-gray-200" style={{ width: `${4 * depth}px` }}></div>
<div className="py-2 px-4">
<p className="font-medium text-gray-800">{relative.name}</p>
<p className="text-sm text-gray-600 md:text-base">
{relation} {list[relative.root].name}
</p>
</div>
</td>
<td className="px-4 py-2">
<td className="px-4">
{showMoney ? (
<p className="text-right text-gray-800">{inheritanceMoney}</p>
) : (
Expand Down Expand Up @@ -151,3 +155,13 @@ function Results({ inheritance, setEditing }: ResultsProps) {
}

export default Results

function countDepth(list: PersonList, id: string): number {
let depth = -1
let currentRelative = list[id]
while (currentRelative.root) {
currentRelative = list[currentRelative.root]
depth += 1
}
return depth
}

1 comment on commit 3bfb3ea

@vercel
Copy link

@vercel vercel bot commented on 3bfb3ea Aug 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.