diff --git a/src/app/lists/components/list-repo-card/list-repo-card.component.ts b/src/app/lists/components/list-repo-card/list-repo-card.component.ts index 8f6ba44..69bf77e 100755 --- a/src/app/lists/components/list-repo-card/list-repo-card.component.ts +++ b/src/app/lists/components/list-repo-card/list-repo-card.component.ts @@ -107,6 +107,6 @@ export class ListRepoCardComponent { public scoreColorLegend: string[] constructor(private repoScoreService: ListRepoScoreService) { - this.scoreColorLegend = repoScoreService.getScoreColors() + this.scoreColorLegend = repoScoreService.getScoreColorTheme() } } diff --git a/src/app/lists/services/list-repo-score/list-repo-score.service.ts b/src/app/lists/services/list-repo-score/list-repo-score.service.ts index 6ce703f..725b864 100755 --- a/src/app/lists/services/list-repo-score/list-repo-score.service.ts +++ b/src/app/lists/services/list-repo-score/list-repo-score.service.ts @@ -27,23 +27,22 @@ export class ListRepoScoreService { } getScoreColor(type: ListRepoScoreType, score: number): { bg: string; text: string } { - const legend = this.getScoreColors() const color = this.getScoreColorScale(type).getColor(score) return { bg: color, - text: this.isColorBright(color) ? legend[legend.length - 2] : legend[1], + text: this.isColorBright(color) ? this.theme[this.theme.length - 2] : this.theme[1], } } - getScoreColors(): string[] { + getScoreColorTheme(): string[] { return this.theme } - isColorBright(hex: string) { - hex = hex.replace('#', '') - const r = parseInt(hex.substr(0, 2), 16), - g = parseInt(hex.substr(2, 2), 16), - b = parseInt(hex.substr(4, 2), 16) + isColorBright(color: string) { + const hex = color.substring(color.length - 6, color.length) + const r = parseInt(hex.substring(0, 2), 16), + g = parseInt(hex.substring(2, 4), 16), + b = parseInt(hex.substring(4, 6), 16) return 150 < (r * 299 + g * 587 + b * 114) / 1000 }