Skip to content

Commit

Permalink
Simplify score and count binding
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmyHoenderdaal committed Jan 15, 2025
1 parent 534d14c commit c77de63
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
13 changes: 4 additions & 9 deletions resources/views/components/stars.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,21 @@
<div class="relative">
<div class="flex gap-0.5">
@for ($star = 0; $star < 5; $star++)
<x-heroicon-s-star class="size-5 text-muted/50" />
<x-heroicon-s-star class="text-muted/50 size-5" />
@endfor
</div>
<div
style="width: {{ (int)$score }}%"
v-bind:style="{ width: ({{ $score }} || 0) + '%'}"
style="width: {{ $score }}%"
class="absolute inset-0 flex gap-0.5 overflow-hidden"
>
@for ($star = 0; $star < 5; $star++)
<x-heroicon-s-star class="size-5 shrink-0 text-yellow-400" />
@endfor
</div>
</div>
@if ($count || $attributes->has('v-bind:count'))
<span
class="text-sm"
@if ($attributes->has('v-bind:count'))
v-text="'(' + ({{ $attributes['v-bind:count'] }} || 0) + ')'"
@endif
>
@if ($count)
<span class="text-sm" v-text="'(' + ({{ $count }} || 0) + ')'">
({{ $count }})
</span>
@endif
Expand Down
2 changes: 1 addition & 1 deletion resources/views/reviews.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div itemprop="reviewRating" itemtype="https://schema.org/Rating" itemscope>
<meta itemprop="ratingValue" v-bind:content="review.average_rating" />
<meta itemprop="bestRating" content="100" />
<x-rapidez-reviews::stars v-bind:score="review.average_rating" />
<x-rapidez-reviews::stars score="review.average_rating" />
</div>
<strong class="block mt-3" itemprop="name">@{{ review.summary }}</strong>
<p class="mt-1 text-sm" itemprop="reviewBody">@{{ review.text }}</p>
Expand Down

0 comments on commit c77de63

Please sign in to comment.