Skip to content

Commit

Permalink
✨ Add icons for StreetComplete Overlays (hard-coded) (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
RobinLinde authored Nov 13, 2024
1 parent c1b924e commit 690ef33
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
43 changes: 43 additions & 0 deletions src/lib/api/getStreetCompleteDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ export async function updateStreetCompleteCache() {
* @returns {Promise<string|null>} A icon url
*/
export async function getStreetCompleteImage(quest: string): Promise<string | null> {
// Check if the quest name ends in Overlay, if so use the overlay function
// Currently these are not included in the quest list, so we have our own function for this
if (quest.endsWith('Overlay')) {
return getStreetCompleteOverlayImage(quest);
}

return (
await prisma.streetCompleteQuest.findFirst({
where: {
Expand All @@ -118,3 +124,40 @@ export async function getStreetCompleteImage(quest: string): Promise<string | nu
})
)?.iconUrl;
}

/**
* Get an icon url from an overlay name
* @param overlay The overlay name
* @returns {Promise<string|null>} A icon url
*/
export async function getStreetCompleteOverlayImage(overlay: string): Promise<string | null> {
// Currently these are not included in the quest list, so we have our own mapping for some of them
const overlayMapping = {
WayLitOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/lantern.svg',
SurfaceOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/street_surface.svg',
SidewalkOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/sidewalk.svg',
CyclewayOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/bicycleway.svg',
StreetParkingOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/parking_lane.svg',
AddressOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/housenumber.svg',
PlacesOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/shop.svg',
ThingsOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/dot.svg',
BuildingsOverlay:
'https://raw.githubusercontent.com/streetcomplete/StreetComplete/refs/heads/master/res/graphics/quest/building.svg'
};

// Check if the overlay is in the mapping
if (overlay in overlayMapping) {
return Promise.resolve(overlayMapping[overlay]);
}

// If not return null
return Promise.resolve(null);
}
1 change: 1 addition & 0 deletions src/routes/[lang]/projects/+page.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export const load: PageServerLoad<{ repos: GithubRepo[] }> = async () => {

if (response.status != 200) {
console.log(`[projects/+page.server.ts]: Status: ${response.status}`);
console.debug(`[projects/+page.server.ts]: Response: ${await response.text()}`);
throw 'Faulty response';
}

Expand Down

0 comments on commit 690ef33

Please sign in to comment.