From 9d4ebf38a7d464af4d5acc825be048917d6f9b82 Mon Sep 17 00:00:00 2001 From: R Fultz Date: Sat, 15 Oct 2022 03:48:05 -0400 Subject: [PATCH 01/22] Changed file names --- ... tabpanel-contributions-across-time.jinja} | 43 +++++-------------- ...s => house-senate-overview-across-time.js} | 0 2 files changed, 11 insertions(+), 32 deletions(-) rename fec/data/templates/partials/house-senate-overview/{election-data.jinja => tabpanel-contributions-across-time.jinja} (83%) rename fec/fec/static/js/pages/{elections-overview.js => house-senate-overview-across-time.js} (100%) diff --git a/fec/data/templates/partials/house-senate-overview/election-data.jinja b/fec/data/templates/partials/house-senate-overview/tabpanel-contributions-across-time.jinja similarity index 83% rename from fec/data/templates/partials/house-senate-overview/election-data.jinja rename to fec/data/templates/partials/house-senate-overview/tabpanel-contributions-across-time.jinja index f7399fff50..b6a229058f 100644 --- a/fec/data/templates/partials/house-senate-overview/election-data.jinja +++ b/fec/data/templates/partials/house-senate-overview/tabpanel-contributions-across-time.jinja @@ -1,36 +1,15 @@ +{# used inside fec/data/templates/house-senate-overview.jinja #} {% import 'macros/null.jinja' as null %} {% import 'macros/disclaimer.jinja' as disclaimer %} {% import 'macros/cycle-select.jinja' as select %} + - \ No newline at end of file diff --git a/fec/data/templates/partials/house-senate-overview/tabpanel-contributions-across-time.jinja b/fec/data/templates/partials/house-senate-overview/tabpanel-contributions-across-time.jinja deleted file mode 100644 index b6a229058f..0000000000 --- a/fec/data/templates/partials/house-senate-overview/tabpanel-contributions-across-time.jinja +++ /dev/null @@ -1,173 +0,0 @@ -{# used inside fec/data/templates/house-senate-overview.jinja #} -{% import 'macros/null.jinja' as null %} -{% import 'macros/disclaimer.jinja' as disclaimer %} -{% import 'macros/cycle-select.jinja' as select %} - - - - \ No newline at end of file diff --git a/fec/data/templates/partials/house-senate-overview/tabpanel-summary.jinja b/fec/data/templates/partials/house-senate-overview/tabpanel-summary.jinja deleted file mode 100644 index 66b11a1ffb..0000000000 --- a/fec/data/templates/partials/house-senate-overview/tabpanel-summary.jinja +++ /dev/null @@ -1,68 +0,0 @@ -{# used inside fec/data/templates/house-senate-overview.jinja #} -{% import 'macros/null.jinja' as null %} -{% import 'macros/disclaimer.jinja' as disclaimer %} -{% import 'macros/cycle-select.jinja' as select %} - - diff --git a/fec/fec/static/js/pages/house-senate-overview-summary.js b/fec/fec/static/js/pages/house-senate-overview-summary.js index 169389fd75..7173b87f2b 100644 --- a/fec/fec/static/js/pages/house-senate-overview-summary.js +++ b/fec/fec/static/js/pages/house-senate-overview-summary.js @@ -7,7 +7,7 @@ import { PartyMoneyBars } from '../modules/party-money-bars'; * @class * @property {HTMLInputElement} cycleSelector - the */ -function HSOverviewSummaryTab() { +function HSOverviewSummary() { this.tabPanel = document.querySelector('#election-summary'); this.cycleSelector = document.querySelector('#election-summary .js-period-select'); @@ -18,10 +18,10 @@ function HSOverviewSummaryTab() { /** * Gets this instance built and working */ -HSOverviewSummaryTab.prototype.init = function() { +HSOverviewSummary.prototype.init = function() { this.cycleSelector.addEventListener('change', this.handleCycleChange.bind(this)); - const theFigures = document.querySelectorAll('#section-election-summary figure'); + const theFigures = document.querySelectorAll('#election-summary figure'); theFigures.forEach(el => { // const elId = el.id; new PartyMoneyBars( @@ -40,7 +40,7 @@ HSOverviewSummaryTab.prototype.init = function() { * Takes an election year, deactivates cycleSelect, and starts the data load * @param {number|string} electionYear - Which election year / cycle to load */ - HSOverviewSummaryTab.prototype.startLoadingData = function(electionYear) { + HSOverviewSummary.prototype.startLoadingData = function(electionYear) { // Only do anything if electionYear is an year between 1970 and 2050 if (parseInt(electionYear) && electionYear >= 1970 && electionYear <= 2050 && electionYear % 2 === 0) { this.deactivateInput(); @@ -84,7 +84,7 @@ HSOverviewSummaryTab.prototype.init = function() { /** * Removes functionality from the input/select assigned to this.cycleSelector */ -HSOverviewSummaryTab.prototype.deactivateInput = function () { +HSOverviewSummary.prototype.deactivateInput = function () { this.cycleSelector.setAttribute('aria-disabled', 'true'); this.cycleSelector.setAttribute('disabled', 'true'); }; @@ -92,7 +92,7 @@ HSOverviewSummaryTab.prototype.deactivateInput = function () { /** * Restores functionality from the input/select assigned to this.cycleSelector */ -HSOverviewSummaryTab.prototype.reactivateInput = function () { +HSOverviewSummary.prototype.reactivateInput = function () { this.cycleSelector.removeAttribute('aria-disabled'); this.cycleSelector.removeAttribute('disabled'); }; @@ -102,7 +102,7 @@ HSOverviewSummaryTab.prototype.reactivateInput = function () { * @param {Event} e - Change event * @param {number} e.target.value - A valid 4-digit integer for an even/election year */ -HSOverviewSummaryTab.prototype.handleCycleChange = function (e) { +HSOverviewSummary.prototype.handleCycleChange = function (e) { this.startLoadingData(e.target.value); }; @@ -111,7 +111,7 @@ HSOverviewSummaryTab.prototype.handleCycleChange = function (e) { * (Takes [{dem numbers}, {rep numbers}, {other numbers}] and converts to [{receipts: {total, dem numbers, rep numbers, other numbers}}]) * @param {object} results - response.results from the api */ -HSOverviewSummaryTab.prototype.handleDataLoaded = function(results) { +HSOverviewSummary.prototype.handleDataLoaded = function(results) { const usefulResults = { total_cash_on_hand_end_period: { total: 0, DEM: 0, REP: 0, Other: 0 }, total_debts_owed_by_committee: { total: 0, DEM: 0, REP: 0, Other: 0 }, @@ -153,7 +153,7 @@ HSOverviewSummaryTab.prototype.handleDataLoaded = function(results) { * Now let's wait for the page to load and start making elements work */ window.addEventListener('load', () => { - new HSOverviewSummaryTab(); + new HSOverviewSummary(); }); -module.exports = { HSOverviewSummaryTab }; +module.exports = { HSOverviewSummary }; From 93ada914060304d0e236f11cf90b1bd68ab245f2 Mon Sep 17 00:00:00 2001 From: R Fultz Date: Thu, 17 Nov 2022 10:02:14 -0500 Subject: [PATCH 14/22] Apply cq classes to election-summary --- .../js/pages/house-senate-overview-summary.js | 3 +++ .../scss/widgets/house-senate-overview.scss | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/fec/fec/static/js/pages/house-senate-overview-summary.js b/fec/fec/static/js/pages/house-senate-overview-summary.js index 7173b87f2b..4b7bdddb05 100644 --- a/fec/fec/static/js/pages/house-senate-overview-summary.js +++ b/fec/fec/static/js/pages/house-senate-overview-summary.js @@ -1,6 +1,7 @@ // import { PartyMoneyBars } from '../modules/party-money-bars'; +import { FECContainerQuery } from '../modules/container-queries'; /** * Runs the Summary tab at /data/elections/house/ and /data/elections/senate/ @@ -34,6 +35,8 @@ HSOverviewSummary.prototype.init = function() { } ); }); + + new FECContainerQuery('#election-summary', '#summary'); }; /** diff --git a/fec/fec/static/scss/widgets/house-senate-overview.scss b/fec/fec/static/scss/widgets/house-senate-overview.scss index 7c16592613..f1fa13f7ef 100644 --- a/fec/fec/static/scss/widgets/house-senate-overview.scss +++ b/fec/fec/static/scss/widgets/house-senate-overview.scss @@ -130,3 +130,22 @@ meter:-moz-meter-optimum::-moz-meter-bar { width: auto !important; } } + +#election-summary { + &.cq-xs { + .cycle-select { + width: auto; + } + .grid--flex .grid__item { + width: 100%; + } + } + &.cq-s { + .cycle-select { + width: auto; + } + .grid--flex .grid__item { + width: 100%; + } + } +} From 8a77d38641d712536d2678867d20a3865836f287 Mon Sep 17 00:00:00 2001 From: R Fultz Date: Thu, 17 Nov 2022 10:02:21 -0500 Subject: [PATCH 15/22] css tweak --- fec/fec/static/scss/widgets/party-money-bars.scss | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fec/fec/static/scss/widgets/party-money-bars.scss b/fec/fec/static/scss/widgets/party-money-bars.scss index 91aefe43f2..bfa6c39d76 100644 --- a/fec/fec/static/scss/widgets/party-money-bars.scss +++ b/fec/fec/static/scss/widgets/party-money-bars.scss @@ -131,6 +131,13 @@ $fontWeightBold: 700; background: $colorBarDef; transition: all 1s; } + &:before { + content: ""; + display: block; + height: 20px; + position: absolute; + border-right: thin solid $colorBarDef; + } &[data-party='DEM'] { &::-webkit-meter-optimum-value { // note#1 @@ -142,6 +149,9 @@ $fontWeightBold: 700; background: $colorBarDem; transition: all 1s; } + &:before { + border-right-color: $colorBarDem; + } } &[data-party='REP'] { &::-webkit-meter-optimum-value { @@ -154,6 +164,9 @@ $fontWeightBold: 700; background: $colorBarRep; transition: all 1s; } + &:before { + border-right-color: $colorBarRep; + } } } // Trying to get the widths to animate when the values change From e95ea76d5593cfc80baf0aa4a34768ce65e8d5ff Mon Sep 17 00:00:00 2001 From: R Fultz Date: Thu, 17 Nov 2022 10:02:48 -0500 Subject: [PATCH 16/22] Add new breadcrumbs for house & senate election overview pages --- fec/data/templates/macros/page-header.jinja | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fec/data/templates/macros/page-header.jinja b/fec/data/templates/macros/page-header.jinja index ba8e7a48a6..91f8483a8f 100644 --- a/fec/data/templates/macros/page-header.jinja +++ b/fec/data/templates/macros/page-header.jinja @@ -28,6 +28,19 @@ {{ links }} + {% elif 'U.S. House elections' in title or 'U.S. Senate elections' in title %} + + + {% else %} {% if title != 'Campaign finance data' %}