Skip to content

Commit

Permalink
Add authority logos at bottom of results
Browse files Browse the repository at this point in the history
## Description

This isn't 100% exactly as designed. The design calls for a white
background that extends horizontally beyond the borders of the
incentive grid. That doesn't work with how this embed element is
implemented: it just fills 100% of the width of its container, so
nothing can extend beyond the grid boundaries. Not sure if what I've
done is an acceptable end state, or if we need to build in a way to
limit the width of the incentive grid without limiting the width of
the logos background.

## Test Plan

See screenshot. Try with different utility selections to make sure
their logos come up. Check narrow and medium layouts to check for
appropriate layout.
  • Loading branch information
oyamauchi committed Sep 26, 2023
1 parent 0f32d67 commit d44acdd
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/api/calculator-types-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ export interface Incentive {
}

export interface APIResponse {
authorities: {
[authorityId: string]: {
name: string;
logo?: {
src: string;
width: number;
height: number;
};
};
};
savings: {
tax_credit: number;
pos_rebate: number;
Expand Down
69 changes: 69 additions & 0 deletions src/authority-logos.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { css, html, nothing } from 'lit';
import { APIResponse } from './api/calculator-types-v1';

export const authorityLogosStyles = css`
.authority-logos {
width: 100%;
max-width: 1280px;
background-color: white;
}
.authority-logos h2 {
text-align: center;
color: #111;
font-size: 2rem;
font-weight: 500;
line-height: 125%;
margin: 48px 24px 64px 24px;
}
/* Tighter margins for the header on small screens */
@media only screen and (max-width: 640px) {
.authority-logos h2 {
font-size: 1.5rem;
margin-top: 32px;
margin-bottom: 48px;
}
}
.authority-logos__container {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: flex-start;
gap: 64px;
margin-bottom: 80px;
}
`;

/**
* Displays the white area at the bottom of the calculator results with logos
* of the authorities whose incentives are displayed.
*/
export const authorityLogosTemplate = (response: APIResponse) => {
if (Object.keys(response.authorities).length === 0) {
return nothing;
}

const logos = Object.values(response.authorities)
.filter(auth => !!auth.logo)
.map(
auth =>
html`<img
src="${auth.logo!.src}"
width="${auth.logo!.width}"
height="${auth.logo!.height}"
/>`,
);

return html`
<div class="authority-logos">
<h2>Incentive data brought to you by</h2>
<div class="authority-logos__container">${logos}</div>
</div>
`;
};
2 changes: 2 additions & 0 deletions src/state-calculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { iconTabBarStyles } from './icon-tab-bar';

import '@shoelace-style/shoelace/dist/components/spinner/spinner';
import { STATES } from './states';
import { authorityLogosStyles } from './authority-logos';

const loadingTemplate = () => html`
<div class="card card-content">
Expand Down Expand Up @@ -50,6 +51,7 @@ export class RewiringAmericaStateCalculator extends LitElement {
utilitySelectorStyles,
separatorStyles,
iconTabBarStyles,
authorityLogosStyles,
];

/* supported properties to control showing/hiding of each card in the widget */
Expand Down
4 changes: 3 additions & 1 deletion src/state-incentive-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { APIResponse, Incentive, ItemType } from './api/calculator-types-v1';
import { exclamationPoint, questionIcon, upRightArrow } from './icons';
import { PROJECTS, Project, shortLabel } from './projects';
import { iconTabBarTemplate } from './icon-tab-bar';
import { authorityLogosTemplate } from './authority-logos';

export const stateIncentivesStyles = css`
.loading {
Expand Down Expand Up @@ -430,5 +431,6 @@ export const stateIncentivesTemplate = (
// If a nonexistent tab is selected, pretend the first one is selected.
otherTabs.includes(selectedOtherTab) ? selectedOtherTab : otherTabs[0],
onTabSelected,
)}`;
)}
${authorityLogosTemplate(response)}`;
};

0 comments on commit d44acdd

Please sign in to comment.