feat: Add new ImageGalleryColumn with options for image display, stacking, and shape, and rename circle() to circular().

This commit is contained in:
al-saloul
2025-12-16 12:32:41 +03:00
parent a66ab88421
commit 8b0a717b71
3 changed files with 15 additions and 15 deletions

View File

@@ -88,7 +88,7 @@ use Alsaloul\ImageGallery\Tables\Columns\ImageGalleryColumn;
ImageGalleryColumn::make('images')
->getStateUsing(fn ($record) => $record->images->pluck('image')->toArray())
->disk(config('filesystems.default'))
->circle()
->circular()
->stacked(3)
->ring(2, '#3b82f6')
->limit(3)
@@ -106,7 +106,7 @@ ImageGalleryColumn::make('images')
| `limit(int\|null)` | Maximum images to show | `3` |
| `stacked(int\|bool)` | Stack thumbnails. Pass `int` for custom spacing | `false` |
| `square(bool)` | Square shape with rounded corners | `false` |
| `circle(bool)` | Circular shape | `false` |
| `circular(bool)` | Circular shape | `false` |
| `ring(int, string)` | Border ring with width and color | `1, null` |
| `ringColor(string)` | Set ring color separately | `null` |
| `limitedRemainingText(bool)` | Show "+N" badge for remaining | `true` |
@@ -159,7 +159,7 @@ ImageGalleryEntry::make('images')
```php
ImageGalleryColumn::make('images')
->disk('s3')
->circle()
->circular()
->stacked(3)
->limit(3)
@@ -173,7 +173,7 @@ ImageGalleryColumn::make('images')
### Circular Stacked with Ring
```php
ImageGalleryColumn::make('images')
->circle()
->circular()
->stacked(3)
->ring(2, '#3b82f6')
->limit(3)

View File

@@ -8,13 +8,13 @@
$isStacked = $isStacked();
$stackedOverlap = $getStackedOverlap();
$isSquare = $isSquare();
$isCircle = $isCircle();
$isCircular = $isCircular();
$ringWidth = $getRingWidth();
$ringColor = $getRingColor();
$galleryId = 'gallery-col-' . str_replace(['{', '}', '-'], '', (string) \Illuminate\Support\Str::uuid());
// Determine border radius class
if ($isCircle) {
if ($isCircular) {
$borderRadiusClass = 'rounded-full';
} elseif ($isSquare) {
$borderRadiusClass = 'rounded-lg';

View File

@@ -22,7 +22,7 @@ class ImageGalleryColumn extends Column
protected bool | Closure $isSquare = false;
protected bool | Closure $isCircle = false;
protected bool | Closure $isCircular = false;
protected int | Closure $ringWidth = 1;
@@ -115,22 +115,22 @@ class ImageGalleryColumn extends Column
return $this->evaluate($this->isSquare);
}
public function circle(bool | Closure $condition = true): static
public function circular(bool | Closure $condition = true): static
{
$this->isCircle = $condition;
$this->isCircular = $condition;
return $this;
}
public function isCircle(): bool
public function isCircular(): bool
{
return $this->evaluate($this->isCircle);
return $this->evaluate($this->isCircular);
}
public function ring(int | Closure $width = 2, string | Closure | null $color = null): static
{
$this->ringWidth = $width;
if ($color !== null) {
$this->ringColor = $color;
}
@@ -219,7 +219,7 @@ class ImageGalleryColumn extends Column
return collect($state)->map(function ($item) use ($disk, $visibility) {
$path = null;
if (is_string($item)) {
$path = $item;
} elseif (is_array($item)) {
@@ -241,11 +241,11 @@ class ImageGalleryColumn extends Column
if ($disk) {
/** @var \Illuminate\Filesystem\FilesystemAdapter $storage */
$storage = Storage::disk($disk);
if ($visibility === 'private') {
return $storage->temporaryUrl($path, now()->addMinutes(5));
}
return $storage->url($path);
}