Skip to content

Commit

Permalink
refactor: add text to progress bars on csrs (#858)
Browse files Browse the repository at this point in the history
  • Loading branch information
iBotPeaches committed Jun 27, 2023
1 parent b947238 commit d06af3f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
24 changes: 15 additions & 9 deletions resources/views/livewire/competitive-page.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
/** @var App\Models\Csr[] $ranked */
/** @var App\Models\Csr[] $current */
?>
<div>
@if ($player->is_private)
Expand Down Expand Up @@ -54,17 +54,23 @@
</td>
<td>
@if (! $playlist->isOnyx())
<span
<div
class="has-tooltip-arrow has-tooltip-text-centered"
data-tooltip="{{ $playlist->getRankPercentTooltip() }}"
>
<progress
class="progress {{ $playlist->getRankPercentColor() }}"
value="{{ $playlist->current_xp_for_level }}"
max="{{ $playlist->next_xp_for_level }}">
%{{ number_format($playlist->next_rank_percent, 2) }}
</progress>
</span>
<div class="progress-wrapper is-clipped">
@if ($playlist->matches_remaining > 0)
<p class="progress-value has-text-white">{{ $playlist->matches_remaining }} matches left.</p>
@else
<p class="progress-value has-text-white">{{ number_format($playlist->csr) }} / {{ number_format($playlist->next_csr) }} CSR</p>
@endif
<progress
class="progress {{ $playlist->getRankPercentColor() }}"
value="{{ $playlist->current_xp_for_level }}"
max="{{ $playlist->next_xp_for_level }}">
</progress>
</div>
</div>
@endif
</td>
</tr>
Expand Down
13 changes: 13 additions & 0 deletions tests/Unit/Models/CsrModelTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,19 @@ public function testNextRankAttribute(
$this->assertEquals($expected, $csr->next_rank);
}

public function testNoPercentWith0Xp(): void
{
// Arrange
$csr = Csr::factory()
->create([
'next_csr' => 1500,
'tier_start_csr' => 1500,
]);

// Act & Assert
$this->assertEquals(0.0, $csr->next_rank_percent);
}

public static function nextRankDataProvider(): array
{
return [
Expand Down

0 comments on commit d06af3f

Please sign in to comment.