-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
started working on customizable colors using css variables
- Loading branch information
1 parent
68cbd2d
commit bdc5771
Showing
13 changed files
with
814 additions
and
741 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,66 @@ | ||
import { Component } from '@angular/core'; | ||
import { Component, OnInit } from "@angular/core"; | ||
import { Config } from "./shared/config"; | ||
|
||
@Component({ | ||
selector: 'app-root', | ||
templateUrl: './app.component.html', | ||
styleUrls: ['./app.component.scss'] | ||
selector: "app-root", | ||
templateUrl: "./app.component.html", | ||
styleUrls: ["./app.component.scss"], | ||
}) | ||
export class AppComponent { | ||
title = 'SpectraFrontend'; | ||
export class AppComponent implements OnInit { | ||
title = "SpectraFrontend"; | ||
|
||
constructor(private config: Config) { } | ||
|
||
ngOnInit(): void { | ||
document.documentElement.style.setProperty( | ||
"--defender-color", | ||
this.config.defenderColor, | ||
); | ||
document.documentElement.style.setProperty( | ||
"--defender-color-rgb", | ||
this.hexToRgb(this.config.defenderColor).join(", "), | ||
); | ||
document.documentElement.style.setProperty( | ||
"--attacker-color", | ||
this.config.attackerColor, | ||
); | ||
document.documentElement.style.setProperty( | ||
"--attacker-color-rgb", | ||
this.hexToRgb(this.config.attackerColor).join(", "), | ||
); | ||
document.documentElement.style.setProperty( | ||
"--defender-color-light", | ||
this.lightenHex(this.config.defenderColor, 30), | ||
); | ||
document.documentElement.style.setProperty( | ||
"--attacker-color-light", | ||
this.lightenHex(this.config.attackerColor, 30), | ||
); | ||
} | ||
|
||
hexToRgb(hex: string): number[] { | ||
hex = hex.replace(/^#/, ""); | ||
|
||
let r = parseInt(hex.substring(0, 2), 16); | ||
let g = parseInt(hex.substring(2, 4), 16); | ||
let b = parseInt(hex.substring(4, 6), 16); | ||
|
||
return [r, g, b]; | ||
} | ||
|
||
lightenHex(hex: string, percent: number): string { | ||
hex = hex.replace(/^#/, ""); | ||
|
||
let r = parseInt(hex.substring(0, 2), 16); | ||
let g = parseInt(hex.substring(2, 4), 16); | ||
let b = parseInt(hex.substring(4, 6), 16); | ||
|
||
// Calculate the amount to lighten | ||
r = Math.min(255, Math.floor(r + (255 - r) * (percent / 100))); | ||
g = Math.min(255, Math.floor(g + (255 - g) * (percent / 100))); | ||
b = Math.min(255, Math.floor(b + (255 - b) * (percent / 100))); | ||
|
||
// Convert back to hex and return | ||
return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,10 @@ | ||
<div class="frame-2"> | ||
<div class="playercards-leftteam"> | ||
<app-playercard | ||
*ngFor="let player of match.teams[0].players; trackBy: trackByPlayerId" | ||
[match]="match" | ||
[player]="player" | ||
[color]="match.teams[0].isAttacking ? 'red' : 'green'" | ||
side="left" | ||
/> | ||
</div> | ||
<div class="playercards"> | ||
<app-playercard | ||
*ngFor="let player of match.teams[1].players; trackBy: trackByPlayerId" | ||
[match]="match" | ||
[player]="player" | ||
[color]="match.teams[1].isAttacking ? 'red' : 'green'" | ||
side="right" | ||
/> | ||
</div> | ||
</div> | ||
<div class="playercards-leftteam"> | ||
<app-playercard *ngFor="let player of match.teams[0].players; trackBy: trackByPlayerId" [match]="match" | ||
[player]="player" [color]="match.teams[0].isAttacking ? 'attacker' : 'defender'" side="left" /> | ||
</div> | ||
<div class="playercards"> | ||
<app-playercard *ngFor="let player of match.teams[1].players; trackBy: trackByPlayerId" [match]="match" | ||
[player]="player" [color]="match.teams[1].isAttacking ? 'attacker' : 'defender'" side="right" /> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,56 @@ | ||
<div class="player-container" [class]="side"> | ||
<!-- <div class="rank-icon-container" *ngIf="match.ranksEnabled && match.ranksByName[player.name]"> | ||
<!-- <div class="rank-icon-container" *ngIf="match.ranksEnabled && match.ranksByName[player.name]"> | ||
<img class="rank-icon" [class]="side" src="{{assets}}/ranks/{{match.ranksByName[player.name]}}_Rank.webp" /> | ||
</div> --> | ||
<div class="agent-icon-container"> | ||
<img class="agent-icon" [class]="player.isAlive ? '' : 'dead'" | ||
src="{{assets}}/agents/{{player.agentInternal}}Icon.webp"/> | ||
<div class="agent-icon-container"> | ||
<img class="agent-icon" [class]="player.isAlive ? '' : 'dead'" | ||
src="{{ assets }}/agents/{{ player.agentInternal }}Icon.webp" /> | ||
</div> | ||
<div class="player-card"> | ||
<div class="player-info" [class]=" | ||
color + | ||
' ' + | ||
(player.isAlive ? 'alive' : 'dead') + | ||
' ' + | ||
(player.isObserved ? 'observed' : '') | ||
"> | ||
<div class="spectator-icon-container" *ngIf="player.isObserved"> | ||
<img class="spectator-icon" src="{{ assets }}/misc/ObserverEye.svg" /> | ||
</div> | ||
<div class="info-container"> | ||
<div class="shields-currency"> | ||
<img class="shield-icon" [class]="color" src="{{ assets }}/shields/{{ player.armorName }}Green.svg" /> | ||
<!--TODO: dynamically change shield color --> | ||
<div class="currency-container" [class]="side"> | ||
<img class="valorant-credits" [class]="color" src="{{ assets }}/misc/ValorantCreditsWhite.svg" /> | ||
<!--TODO: dynamically change currency color--> | ||
<div class="currency-title" [class]="color">{{ player.money }}</div> | ||
</div> | ||
</div> | ||
<div class="username-container"> | ||
<div class="username-title" [class]="side">{{ player.name }}</div> | ||
<img class="captain-icon" *ngIf="player.isCaptain" src="{{ assets }}/misc/TeamCaptain.svg" /> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="player-card"> | ||
<div class="player-info" [class]="color + ' ' + (player.isAlive ? 'alive' : 'dead') + ' ' + (player.isObserved ? 'observed' : '')"> | ||
<div class="spectator-icon-container" *ngIf="player.isObserved"> | ||
<img class="spectator-icon" src="{{assets}}/misc/ObserverEye.svg" /> | ||
</div> | ||
<div class="info-container"> | ||
<div class="shields-currency"> | ||
<img class="shield-icon" src="{{assets}}/shields/{{player.armorName}}{{capitalizeColor(color)}}.svg" /> | ||
<div class="currency-container" [class]="side"> | ||
<img class="valorant-credits" src="{{assets}}/misc/ValorantCredits{{capitalizeColor(color)}}.svg" /> | ||
<div class="currency-title" [class]="color">{{player.money}}</div> | ||
</div> | ||
</div> | ||
<div class="username-container"> | ||
<div class="username-title" [class]="side">{{player.name}}</div> | ||
<img class="captain-icon" *ngIf="player.isCaptain" src="{{assets}}/misc/TeamCaptain.svg" /> | ||
</div> | ||
</div> | ||
<div class="utility-container" [class]="color" *ngIf="player.isAlive" [@deathAnimation]="player.isAlive"> | ||
<div class="weapon-icon-wrapper"> | ||
<img class="weapon-icon" src="{{ assets }}/weapons/{{ player.highestWeapon }}Killfeed.webp" /> | ||
</div> | ||
<div class="ultimate-tracker-container"> | ||
<div class="ultimate-tracker" [class]="side" *ngIf="!player.ultReady" [@ultPipAnimation]> | ||
<div class="pip-ultimate-full" *ngFor="let i of numSequence(player.currUltPoints)"></div> | ||
<div class="pip-ultimate" *ngFor=" | ||
let i of numSequence(player.maxUltPoints - player.currUltPoints) | ||
"></div> | ||
</div> | ||
<div class="ultimate-tracker" [class]="side" *ngIf="player.ultReady" [@ultImageAnimation]> | ||
<img class="ultimate-full-image" src="{{ assets }}/ultimates/{{ player.agentInternal }}Ultimate.webp" /> | ||
</div> | ||
<div class="utility-container" [class]="color" *ngIf="player.isAlive" [@deathAnimation]="player.isAlive"> | ||
<div class="weapon-icon-wrapper"> | ||
<img class="weapon-icon" | ||
src="{{assets}}/weapons/{{player.highestWeapon}}Killfeed.webp" /> | ||
</div> | ||
<div class="ultimate-tracker-container"> | ||
<div class="ultimate-tracker" [class]="side" *ngIf="!player.ultReady" [@ultPipAnimation]> | ||
<div class="pip-ultimate-full" *ngFor="let i of numSequence(player.currUltPoints)"></div> | ||
<div class="pip-ultimate" *ngFor="let i of numSequence(player.maxUltPoints - player.currUltPoints)"></div> | ||
</div> | ||
<div class="ultimate-tracker" [class]="side" *ngIf="player.ultReady" [@ultImageAnimation]> | ||
<img class="ultimate-full-image" src="{{assets}}/ultimates/{{player.agentInternal}}Ultimate.webp"> | ||
</div> | ||
<div class="spike-icon-wrapper"> | ||
<img class="spike-icon" *ngIf="player.hasSpike" src="{{assets}}/misc/Spike_Icon.svg" /> | ||
</div> | ||
</div> | ||
<div class="spike-icon-wrapper"> | ||
<img class="spike-icon" *ngIf="player.hasSpike" src="{{ assets }}/misc/Spike_Icon.svg" /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
Oops, something went wrong.