Skip to content

Commit

Permalink
#17 added top line amounts to summary -- color coded baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
katrina-cityofdetroit committed Jul 18, 2024
1 parent e27fb08 commit 4f2a9d9
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,22 @@ <h2 id="subtitle"></h2>
<!-- Summary page accordion -->
<div id='accordion-div'>
<div id='baseline-accordion' class="summary-container">
<h3 id="baseline-title" class="accordion-title">Baseline</h3>
<h3 id="baseline-title" class="accordion-title">
Baseline
<span class="top-line-amount cost"></span>
</h3>
<div class="accordion summary-accordion"></div>
</div>
<div id="supp-accordion" class="summary-container">
<h3 id="supp-title" class="accordion-title">Suplemental
<button class="btn btn-add-init">Add another initiative</button>
<h3 id="supp-title" class="accordion-title">
Suplemental
<span class="top-line-amount cost"></span>
</h3>
<div class="accordion summary-accordion"></div>
</div>
<div class="add-init-btn-div">
<button class="btn btn-add-init">Add another initiative</button>
</div>
</div>

<!-- Space for an initial prompt and response buttons -->
Expand Down
17 changes: 14 additions & 3 deletions src/js/components/accordion/accordion.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,11 @@ span.amount {
.btn-add-init {
background-color: var(--spiritgreen);
border-color: var(--citygreen);
position: absolute;
/* position: absolute; */
right: 0;
margin-right: calc(20vw + 15px);
margin-top: -8px;
/* margin-left: 20px; */
/* margin-right: calc(20vw + 15px); */
margin-top: 15px;
}

#supp-title {
Expand All @@ -67,4 +68,14 @@ span.amount {

.btn-add-init:hover {
background-color: var(--palegreen);
}
.add-init-btn-div{
text-align: center;
}

span.top-line-amount {
font-weight: bold;
position: absolute;
right: 0;
margin-right: calc(20vw + 20px);
}
20 changes: 19 additions & 1 deletion src/js/components/accordion/accordion.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import './accordion.css'

import { CurrentFund, Fund, Supplemental } from "../../utils/data_utils/local_storage_handlers.js";
import { Baseline, CurrentFund, Fund, Supplemental } from "../../utils/data_utils/local_storage_handlers.js";
import { formatCurrency, cleanString } from "../../utils/common_utils.js";
import Table from "../table/table.js";
import { FundLookupTable } from "../../utils/data_utils/budget_data_handlers.js";
import { visitPage } from '../../views/view_logic.js';
import { TARGET } from '../../init.js';

function redirectForEdit(){
const row = document.querySelector(`.active-editing`);
Expand Down Expand Up @@ -150,12 +151,29 @@ export const Accordion = {
Item.updateHeader(program.name, program.name, program.net());
});
},
updateTopLines() {
// adjuse baseline
const baseline = new Baseline;
const baselineAmount = document.querySelector('#baseline-title .top-line-amount')
baselineAmount.textContent = formatCurrency(baseline.total());
// adjust supplementals
const supp = new Supplemental;
const suppAmount = document.querySelector('#supp-title .top-line-amount')
suppAmount.textContent = formatCurrency(supp.total());
// color-code baseline
if (baseline.total() <= TARGET){
baselineAmount.style.color = 'green';
} else {
baselineAmount.style.color = 'red';
}
},
build() {
this.createBaseline();
this.createSupp();
// initialize edit buttons
Table.Buttons.Edit.init(redirectForEdit);
this.AddInitButton.init();
this.updateTopLines();
}
}

Expand Down

0 comments on commit 4f2a9d9

Please sign in to comment.