Skip to content

Commit

Permalink
Merge pull request #388 from caciviclab/feat/more-summary-page
Browse files Browse the repository at this point in the history
Add 3 more sections to election summary page
  • Loading branch information
ckingbailey authored Jul 17, 2020
2 parents 425078b + 3b23ccd commit 56d0eac
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 6 deletions.
57 changes: 52 additions & 5 deletions _includes/election-summary.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,67 @@
<div class="election-summary">
<section class="l-section election-summary__total">
<div class="election-summary__total-header">Total contributions reported for this election</div>
<div class="election-summary__total-amount">{{data_totals['total_contributions'] | dollars}}</div>
<div class="election-summary__total-amount">{{ data_totals.total_contributions | dollars }}</div>
</section>

<section class="l-section">
<div class="l-section__content">
<h2>Top 3 Most Expensive Races</h2>
<h3>Top 3 Most Expensive Races</h3>
</div>
<div class="l-section__content">
{% for race in data_totals['most_expensive_races'] %}
{% for race in data_totals.most_expensive_races %}
<div>
<a href="/{{race['type']}}/{{ballot.locality}}/{{ballot.slug}}/{{race['slug']}}/">{{race['title']}}</a>
<span class="election-summary__race-amount">{{race['amount'] | dollars}}</span>
<a href="/{{race.type}}/{{ballot.locality}}/{{ballot.slug}}/{{race.slug}}/">{{ race.title }}</a>
<span class="election-summary__race-amount">{{ race.amount | dollars }}</span>
</div>
{% endfor %}
</div>
</section>
<section class="l-section">
<div class="l-section__content">
<h3>Who is contributing to races on this ballot?</h3>
</div>
<div class="l-section__content">
{% for contribution_type in election_totals.contributions_by_type %}
{% assign amount = contribution_type[1] %}
{% assign type_name = contribution_type[0] %}
{% include money-bar.html label=type_name value=amount color="green" max=data_totals.total_contributions %}
{% endfor %}
</div>
</section>
<section class="l-section">
<div class="l-section__content">
<h3>Candidates with the largest proportion of small contributions (under $100)</h3>
</div>
<div class="l-section__content">
<ul class="no-bullet-list">
{% for candidate in election_totals.largest_small_proportion %}
<li class="grid grid--full">
<span class="grid-col-11">
<a
href="{{ site.baseurl }}/candidate/{{ ballot.locality }}/{{ ballot.slug }}/{{ candidate.slug }}"
>{{ candidate.candidate }}</a>, {{ candidate.office_title }}
</span>
<span class="grid-col-1 align-right">{{ candidate.proportion | times: 100 | round: 1 }}%</span>
</li>
{% endfor %}
</ul>
</div>
</section>
<section class="l-section">
<div class="l-section__content">
<h3>Where is the money coming from?</h3>
</div>
<div class="l-section__content">
<ul class="no-bullet-list">
{% for source in election_totals.total_contributions_by_source %}
<li class="grid">
{% assign place=source[0] %}
{% assign amount=source[1] %}
{% include money-bar.html label=place value=amount color="green" max=data_totals.total_contributions %}
</li>
{% endfor %}
</ul>
</div>
</section>
</div>
3 changes: 2 additions & 1 deletion _layouts/ballot.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
{% assign today = site.time | date: "%Y-%m-%d" %}
{% assign current_election = locality.current_election | date: "%B %-d, %Y" %}
{% assign data_totals = site.data.totals[ballot.election_id] %}
{% assign election_totals = site.data.elections[ballot.locality][ballot.election] %}

{% capture body %}
<header>
<h1>Data for {{ballot.locality | capitalize}} Election on {{ballot.election | date: "%B %-d, %Y"}}</h1>
<h2>Data for {{ballot.locality | capitalize}} Election on {{ballot.election | date: "%B %-d, %Y"}}</h2>
</header>
{% include election-summary.html %}
{% endcapture %}
Expand Down
6 changes: 6 additions & 0 deletions _sass/base/_elements.scss
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ nav {
}
}

.no-bullet-list {
margin: 0;
padding: 0;
list-style: none;
}

table {
border-collapse: collapse;
}
Expand Down
4 changes: 4 additions & 0 deletions _sass/base/_typography.scss
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,7 @@ a:hover {
font-size: $small-font-size;
font-style: italic;
}

.align-right {
text-align: right;
}
7 changes: 7 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ gulp.task('clean', function () {
'_referendums',
'_data/candidates',
'_data/committees',
'_data/elections',
'_data/referendum_opposing',
'_data/referendum_supporting',
'_data/stats.json',
Expand All @@ -35,6 +36,11 @@ gulp.task('pull:elections', function () {
.pipe(gulp.dest('_elections'));
});

gulp.task('pull:elections-totals', function () {
return gulp.src(dataDir('_data', 'elections', '**', '*.json'))
.pipe(gulp.dest('_data/elections'));
})

gulp.task('pull:referendums', function () {
return gulp.src(dataDir('_referendums', '**', '*.md'))
.pipe(gulp.dest('_referendums'));
Expand Down Expand Up @@ -93,6 +99,7 @@ gulp.task('pull:totals', function () {
gulp.task('pull', gulp.parallel(
'pull:ballots',
'pull:elections',
'pull:elections-totals',
'pull:candidates',
'pull:candidates-finance',
'pull:committees',
Expand Down

0 comments on commit 56d0eac

Please sign in to comment.