Skip to content

Commit 4d2e674

Browse files
Merge pull request #28 from redsquirrelstudio/feature_infolist-entry
Added Infolist entry component
2 parents dfdf0d7 + ed0b2f8 commit 4d2e674

File tree

3 files changed

+64
-0
lines changed

3 files changed

+64
-0
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@ return $table
7474
])
7575
```
7676

77+
With Infolist :
78+
79+
```php
80+
use IbrahimBougaoua\FilamentRatingStar\Entries\Components\RatingStar;
81+
82+
return $infolist
83+
->schema([
84+
RatingStar::make('rating')
85+
])
86+
```
87+
7788
You can use the `size` method to customize the size of the stars:
7889

7990
```php
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<x-dynamic-component :component="$getEntryWrapperView()" :entry="$entry">
2+
@php
3+
$state = $getState();
4+
$isRTL = config('filament-rating-star.isRTL');
5+
$direction = $isRTL ? 'rtl' : 'ltr';
6+
$size = match ($getSize()) {
7+
'xs' => 12,
8+
'sm' => 18,
9+
'md' => 22,
10+
'lg' => 28,
11+
'xl' => 36,
12+
};
13+
@endphp
14+
15+
<div class="flex p-10" dir="{{ $direction }}">
16+
@for ($i = 1; $i <= count(config('filament-rating-star.stars')); $i++)
17+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30" width="{{ $size }}" height="{{ $size }}">
18+
<path
19+
d="M15.765,2.434l2.875,8.512l8.983,0.104c0.773,0.009,1.093,0.994,0.473,1.455l-7.207,5.364l2.677,8.576 c0.23,0.738-0.607,1.346-1.238,0.899L15,22.147l-7.329,5.196c-0.63,0.447-1.468-0.162-1.238-0.899l2.677-8.576l-7.207-5.364 c-0.62-0.461-0.3-1.446,0.473-1.455l8.983-0.104l2.875-8.512C14.482,1.701,15.518,1.701,15.765,2.434z"
20+
fill="{{ ($state >= $i) ? '#ffc107' : '#ddd' }}"/>
21+
</svg>
22+
@endfor
23+
</div>
24+
</x-dynamic-component>

src/Entries/Components/RatingStar.php

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
namespace IbrahimBougaoua\FilamentRatingStar\Entries\Components;
4+
5+
use Filament\Forms\Components\Concerns\HasToggleColors;
6+
use Filament\Forms\Components\Concerns\HasToggleIcons;
7+
use Filament\Infolists\Components\Entry;
8+
9+
class RatingStar extends Entry
10+
{
11+
use HasToggleColors;
12+
use HasToggleIcons;
13+
14+
protected string $view = 'filament-rating-star::entries.components.rating-star';
15+
16+
protected string $size = 'lg';
17+
18+
public function size(string $size): static
19+
{
20+
$this->size = $size;
21+
22+
return $this;
23+
}
24+
25+
public function getSize(): string
26+
{
27+
return $this->size;
28+
}
29+
}

0 commit comments

Comments
 (0)