diff --git a/18-expenses-chart/templates/index.templ b/18-expenses-chart/templates/index.templ index 841755d..7ef64bc 100644 --- a/18-expenses-chart/templates/index.templ +++ b/18-expenses-chart/templates/index.templ @@ -21,7 +21,10 @@ func prepareSummaryComponent(expenses []float32) templ.Component { for _, price := range expenses { percentages = append(percentages, price/max) } - return spendingSummaryComponent(expenses, percentages) + + currentDayNum := 2 + + return spendingSummaryComponent(expenses, percentages, currentDayNum) } css expenseBarVars(percentage float32) { @@ -29,29 +32,32 @@ css expenseBarVars(percentage float32) { transform: scaleY(var(--height-percentage)); } -templ dayExpenseColumn(expense, percentage float32, day string) { +templ dayExpenseColumn(expense, percentage float32, day string, isCurrentDay bool) {

{ day }

} // The 7 vertical bars of the per-day expenses -templ expensesChart(expenses, percentages []float32) { +templ expensesChart(expenses, percentages []float32, currentDayNum int) {
for i := 0; i < 7; i++ { - @dayExpenseColumn(expenses[i], percentages[i], days[i]) + @dayExpenseColumn(expenses[i], percentages[i], days[i], currentDayNum == i) }
} // Big container with chard and total expenses of the week -templ spendingSummaryComponent(expenses, percentages []float32) { +templ spendingSummaryComponent(expenses, percentages []float32, currentDayNum int) {
Spending - Last 7 days - @expensesChart(expenses, percentages) + @expensesChart(expenses, percentages, currentDayNum)