diff --git a/islands/BudgetCard.tsx b/islands/BudgetCard.tsx index 0a41316..b6e78cf 100644 --- a/islands/BudgetCard.tsx +++ b/islands/BudgetCard.tsx @@ -2,8 +2,9 @@ import { JSX } from 'preact/jsx-runtime' import { Budget } from '../models.ts' import { Currency } from '../components/Currency.tsx' import { Percentage } from '../components/Percentage.tsx' +import { Component } from 'https://esm.sh/stable/preact@10.19.6/denonext/preact.mjs' -export function BudgetCard( +function BudgetCardLit( { budget, ...props }: & { budget: Budget } & JSX.HTMLAttributes, @@ -30,8 +31,6 @@ export function BudgetCard(
- - {remainingRatio >= 0 ? ` left ` : ` over `}
@@ -64,3 +63,73 @@ export function BudgetCard(
) } + +export function BudgetCard( + { budget, ...props }: + & { budget: Budget } + & JSX.HTMLAttributes, +) { + const remainingRatio = 1.0 - (budget.spent / budget.target) + const bgClass = (remainingRatio < 0 ? 'bg-red' : 'bg-green') + ' opacity-10' + const accentTextClass = remainingRatio < 0 ? 'text-red' : 'text-green' + + return ( + + + {remainingRatio >= 0 ? ` left ` : ` over `} + + } + {...props} + > + + of{' '} + + {' spent '} + ( remaining) + + + ) +} + +interface ProgressBarCardProps { + heading: string + subheading: JSX.Element + bgClass: string + accentTextClass: string + ratio: number +} +export function ProgressBarCard( + { heading, subheading, bgClass, accentTextClass, ratio, children, ...props }: + & ProgressBarCardProps + & JSX.HTMLAttributes, +) { + return ( +
+
+

+ {heading} +

+
+ + {subheading} + +
+ {children} +
+
+ ) +} diff --git a/islands/Dashboard.tsx b/islands/Dashboard.tsx index 38b7758..a6b6b95 100644 --- a/islands/Dashboard.tsx +++ b/islands/Dashboard.tsx @@ -98,7 +98,7 @@ export default function Dashboard() {

FlanBank

-
+
{/*

Budgets Overview

*/}
diff --git a/models.ts b/models.ts index a2b2a91..c04836d 100644 --- a/models.ts +++ b/models.ts @@ -3,6 +3,7 @@ export interface Budget { target: number buffer?: number spent: number + color?: string } export interface Bucket {