Skip to content

Commit

Permalink
Switch into scorecard
Browse files Browse the repository at this point in the history
  • Loading branch information
tunglinn committed May 31, 2024
1 parent b8302bd commit 593680e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
8 changes: 8 additions & 0 deletions src/css/_scorecard.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
$teal: #21ccb9;
$opaque-yellow: #fae678e2;
$gray: rgb(60, 60, 60);

.popup-fixed {
position: fixed;
Expand Down Expand Up @@ -83,6 +85,12 @@ div.popup-button a:hover {
border: 1px solid $teal;
}

.community-tag {
font-size: 14px;
background-color: $opaque-yellow;
color: $gray;
}

@media only screen and (max-width: 830px) {
.leaflet-popup-content-wrapper {
overflow-y: scroll;
Expand Down
4 changes: 3 additions & 1 deletion src/js/fontAwesome.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
faLink,
faUpRightFromSquare,
faCheck,
faTriangleExclamation,
} from "@fortawesome/free-solid-svg-icons";
import "@fortawesome/fontawesome-svg-core/styles.css";

Expand All @@ -14,7 +15,8 @@ const setUpIcons = (): void => {
faCircleXmark,
faLink,
faUpRightFromSquare,
faCheck
faCheck,
faTriangleExclamation
);
dom.watch();
};
Expand Down
28 changes: 10 additions & 18 deletions src/js/setUpSite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ const generateScorecard = (entry: ScoreCardDetails): string => {
<i class="share-check-icon fa-solid fa-check fa-xl" title="Link Copied!" style="display: none"></i>
</a>
</div>
<hr>
`;

const lines = [];
Expand All @@ -105,6 +104,13 @@ const generateScorecard = (entry: ScoreCardDetails): string => {
);
};

if ("contribution" in entry) {
lines.push(
`<div><span class="community-tag"><i class="fa-solid fa-triangle-exclamation"></i> Community-maintained map. <br>Email ${entry.contribution} for issues.<span><div>`
);
}
lines.push("<hr>");

addEntry("Parking", `${entry.percentage} of central city`);
if (entry.parkingScore) {
addEntry("Parking score", entry.parkingScore);
Expand Down Expand Up @@ -153,10 +159,7 @@ const snapToCity = (map: Map, layer: ImageOverlay): void => {
/**
* Sets scorecard to city and alert if city is community made.
*/
const setScorecardAndAlert = (
cityId: CityId,
cityProperties: ScoreCard
): void => {
const setScorecard = (cityId: CityId, cityProperties: ScoreCard): void => {
const { layer, details } = cityProperties;
const scorecard = generateScorecard(details);
setUpShareUrlClickListener(cityId);
Expand All @@ -166,17 +169,6 @@ const setScorecardAndAlert = (
autoPan: false,
}).setContent(scorecard);
layer.bindPopup(popup).openPopup();

const alertBox = document.getElementById(
"community-map-alert"
) as HTMLElement;
if ("contribution" in details) {
const email = document.getElementById("email") as HTMLSpanElement;
email.innerText = details.contribution;
alertBox.style.display = "block";
} else {
alertBox.style.display = "none";
}
};

/**
Expand Down Expand Up @@ -210,7 +202,7 @@ const setUpAutoScorecard = async (
});
if (centralCity) {
DROPDOWN.setChoiceByValue(centralCity);
setScorecardAndAlert(centralCity, cities[centralCity]);
setScorecard(centralCity, cities[centralCity]);
}
});
};
Expand Down Expand Up @@ -270,7 +262,7 @@ const setUpCitiesLayer = async (
const cityId = cityToggleElement.value;
setUpAutoScorecard(map, cities, parkingLayer);
snapToCity(map, cities[cityId].layer);
setScorecardAndAlert(cityId, cities[cityId]);
setScorecard(cityId, cities[cityId]);
} else {
throw new Error("#city-choice is not a select element");
}
Expand Down

0 comments on commit 593680e

Please sign in to comment.