Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions components/finance/FinanceCategories/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ const FinanceCategories = ({ columns, activeCell, setActiveCell }: financeCatego
incomeOrExpense
order
id
plannedTotal
actualTotal
balanceTotal
}
}
`
Expand Down
10 changes: 10 additions & 0 deletions components/finance/FinanceCategoryList/CategorySummary.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
.finance-category-summary-container {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Can you use Tailwind instead of CSS to style this?

height: 100%;
background-color: #f16c6c;
padding-left: 0;
padding: 0.625rem 0;
}
.finance-category-summary-details {
padding-left: 0.625rem;
font-size: 11px;
}
21 changes: 21 additions & 0 deletions components/finance/FinanceCategoryList/CategorySummary.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
type categoriesSummaryProps = {
balanceTotal: number
plannedTotal: number
actualTotal: number
}

const CategorySummary = ({
balanceTotal,
plannedTotal,
actualTotal
}: categoriesSummaryProps) => {
return (
<div className="finance-category-summary-container" style={{width: `${balanceTotal >= 100 ? 100 : balanceTotal}%`}}>
<span className="finance-category-summary-details">
{ balanceTotal >= 100 ? 'Exceeds by 100' : plannedTotal - actualTotal }
</span>
</div>
)
}

export default CategorySummary;
11 changes: 9 additions & 2 deletions components/finance/FinanceCategoryList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import CategorySummary from './CategorySummary'

function FinanceCategoryList({ item, rowIndex, activeRow, summaryOnClick }: any) {
return (
Expand All @@ -14,10 +15,16 @@ function FinanceCategoryList({ item, rowIndex, activeRow, summaryOnClick }: any)
{item.name}
</div>
<div
className={`p-2.5 w-24 text-center ${
className={`w-24 text-center ${
item.incomeOrExpense === 'expense' ? 'bg-plannedExpense' : 'bg-plannedIncome'
}`}
/>
>
<CategorySummary
balanceTotal={item.balanceTotal}
plannedTotal={item.plannedTotal}
actualTotal={item.actualTotal}
/>
</div>
</>
)
}
Expand Down
1 change: 1 addition & 0 deletions pages/_app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/* eslint-disable global-require */

import '../styles/global.css'
import '../components/finance/FinanceCategoryList/CategorySummary.css';

import { ApolloProvider } from '@apollo/client'
import { UserProvider } from '@auth0/nextjs-auth0'
Expand Down