Skip to content

Commit

Permalink
UI (website): add icons for achievement categories
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastientromp committed Jun 10, 2023
1 parent 8188c1e commit 5849af4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import { ChangeDetectionStrategy, Component, Input } from '@angular/core';
</i>
</div>
<span class="text set-name" [helpTooltip]="displayName">{{ displayName }}</span>
<i class="logo" [inlineSVG]="categoryIcon"> </i>
<i class="logo"*ngIf="categoryIcon" [inlineSVG]="categoryIcon"> </i>
<img class="logo"*ngIf="categoryImage" [src]="categoryImage" />
<progress-bar [current]="achieved" [total]="totalAchievements"></progress-bar>
</div>
`,
Expand All @@ -39,6 +40,7 @@ export class AchievementCategoryViewComponent {
@Input() complete: boolean;
@Input() displayName: string;
@Input() categoryIcon: string;
@Input() categoryImage: string;
@Input() achieved: number;
@Input() totalAchievements: number;
}
25 changes: 24 additions & 1 deletion libs/website/profile/src/lib/+state/website/profile.effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class WebsiteProfileEffects {
refCategory?.locales?.find((loc) => loc.locale === this.i18n.locale)?.name ??
refCategory?.name ??
'',
categoryIcon: '',
categoryImage: this.buildAchievementCategoryImage(category.id),
};
}) ?? [];
const extendedProfile: ExtendedProfile = {
Expand All @@ -180,4 +180,27 @@ export class WebsiteProfileEffects {
};
return extendedProfile;
}

private buildAchievementCategoryImage(id: number): string {
const imageName = this.buildAchievementCategoryImageName(id);
return !!imageName?.length
? `https://static.zerotoheroes.com/hearthstone/asset/firestone/images/achievements/${imageName}.webp`
: '';
}
buildAchievementCategoryImageName(id: number): string | null {
switch (id) {
case 1:
return 'AchievementPin_Progression';
case 2:
return 'AchievementPin_Gameplay';
case 3:
return 'AchievementPin_Collection';
case 4:
return 'AchievementPin_Adventures';
case 6:
return 'AchievementPin_GameModes1';
default:
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ export interface ExtendedProfileAchievementCategory extends ProfileAchievementCa
readonly empty: boolean;
readonly complete: boolean;
readonly displayName: string;
readonly categoryIcon: string;
readonly categoryImage: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { getAchievementCategories } from '../+state/website/profile.selectors';
[empty]="category.empty"
[complete]="category.complete"
[displayName]="category.displayName"
[categoryIcon]="category.categoryIcon"
[categoryImage]="category.categoryImage"
[achieved]="category.completedAchievements"
[totalAchievements]="category.totalAchievements"
>
Expand Down

0 comments on commit 5849af4

Please sign in to comment.