this.handleMapSelection(map.type)}
class="cursor-pointer"
>
this.handleToggleFavorite(map.type)}
.translation=${translateText(map.translationKey)}
>
`;
}
private renderMapGrid(mapList: MapInfo[]) {
// Keyed by map so cards keep their identity when the list shifts
// (e.g. the selected map gets prepended to the featured grid) —
// positional reuse would leave stale thumbnails behind.
return html`
${repeat(
mapList,
(map) => map.id,
(map) => this.renderMapCard(map),
)}
`;
}
private renderSectionHeading(label: string) {
return html`
${this.renderSectionHeading(translateText("map_categories.featured"))}
${this.renderMapGrid(featuredMapList)}
`;
}
private renderAllTab() {
return html`
${mapCategoryOrder
.filter((categoryKey) => categoryKey !== "featured")
.map((categoryKey) =>
this.renderCategoryBar(categoryKey, mapsInCategory(categoryKey)),
)}
`;
}
private renderFavoritesTab() {
if (this.favorites.length === 0) {
return html`
${starIcon(false, "w-8 h-8")}
${translateText("map_component.favorites_empty")}
`;
}
const favoriteMaps = this.favorites
.map((favorite) => maps.find((m) => m.type === favorite))
.filter((m) => m !== undefined);
return html`
${this.renderSectionHeading(translateText("map_categories.favorites"))}
${this.renderMapGrid(favoriteMaps)}
`;
}
private renderActiveTab() {
switch (this.activeTab) {
case "all":
return this.renderAllTab();
case "favorites":
return this.renderFavoritesTab();
default:
return this.renderFeaturedTab();
}
}
private renderTabButton(tab: MapTab, label: string) {
const isActive = this.activeTab === tab;
return html`
${this.renderTabButton("featured", translateText("map.featured"))}
${this.renderTabButton("all", translateText("map.all"))}
${this.renderTabButton("favorites", translateText("map.favorites"))}
${this.renderActiveTab()}
${this.renderSectionHeading(translateText("map_categories.special"))}
${translateText("map.random")}
`;
}
}