Skip to content

Commit d7fbeeb

Browse files
Lui Wing LeungLui Wing Leung
authored andcommitted
v1.4.0: Add double-click zoom functionality and comprehensive Filament 3.0+/4.0+ documentation
- Add double-click zoom: toggle between fit-to-container and 2x zoom - Update all Blade templates with @DBLClick event handler - Add comprehensive Filament version compatibility documentation - Include side-by-side examples for 3.0+ and 4.0+ - Add version-specific troubleshooting and key differences - Update changelog with detailed version history - Enhanced user experience with intuitive zoom controls
1 parent 18805b4 commit d7fbeeb

8 files changed

Lines changed: 257 additions & 25 deletions

File tree

CHANGELOG.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,64 @@
22

33
All notable changes to `filament-panzoom` will be documented in this file.
44

5+
## 1.4.0 - 2024-08-20
6+
7+
### Added
8+
- **Double-click zoom functionality**: Double-click on the image to toggle between fit-to-container and 2x zoom
9+
- Enhanced user experience with intuitive zoom controls
10+
11+
## 1.3.0 - 2024-08-20
12+
13+
### Added
14+
- **Filament 4.0 compatibility**: Full support for Filament 4.0+ with conditional component base class selection
15+
- Runtime detection of Filament version (3.x vs 4.x)
16+
- Automatic selection of correct base class (`Filament\Schemas\Components\Component` for 4.x, `Filament\Forms\Components\Component` for 3.x)
17+
18+
### Changed
19+
- Updated component inheritance to support both Filament 3.x and 4.x architectures
20+
- Improved compatibility detection and error handling
21+
22+
## 1.2.5 - 2024-08-20
23+
24+
### Fixed
25+
- Resolved `ArgumentCountError` in Infolist component by removing complex wrapper logic
26+
- Simplified `pan-zoom-entry.blade.php` to render content directly
27+
28+
## 1.2.4 - 2024-08-20
29+
30+
### Fixed
31+
- Fixed `ArgumentCountError` in Infolist component by using direct entry wrapper
32+
33+
## 1.2.3 - 2024-08-20
34+
35+
### Fixed
36+
- Fixed `Undefined variable $entry` error in Infolist component
37+
- Added explicit variable assignment in Blade template
38+
39+
## 1.2.2 - 2024-08-20
40+
41+
### Fixed
42+
- Re-introduced separate `PanZoomEntry` component for Infolists to resolve `TypeError`
43+
- Added clear documentation about component selection based on context
44+
45+
## 1.2.1 - 2024-08-20
46+
47+
### Fixed
48+
- Removed conflicting `EvaluatesClosures` trait usage to resolve `FatalError`
49+
- Fixed "Class was composed with trait conflicts" error
50+
51+
## 1.2.0 - 2024-08-20
52+
53+
### Changed
54+
- Attempted universal component approach (reverted in 1.2.2)
55+
- Updated documentation for simplified usage
56+
57+
## 1.1.0 - 2024-08-20
58+
59+
### Added
60+
- Introduced `PanZoom::make()` component for simplified usage
61+
- Added comprehensive installation and usage documentation
62+
563
## 1.0.1 - 2024-08-19
664

765
### Fixed

README.md

Lines changed: 167 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ An interactive image zoom and pan component for Filament PHP. This package provi
1010
**Features:**
1111
- 🔍 Mouse wheel zooming
1212
- 🖱️ Click and drag panning
13+
- 🖱️ Double-click zoom in/out
1314
- 📱 Touch support for mobile devices
1415
- ⚡ Smooth transitions and animations
1516
- 🎯 Zoom in/out buttons
@@ -68,9 +69,67 @@ php artisan vendor:publish --tag="filament-panzoom-config"
6869

6970
## Usage
7071

72+
### Filament Version Compatibility
73+
74+
This package supports both **Filament 3.0+** and **Filament 4.0+** with automatic compatibility detection.
75+
76+
#### Filament 3.0+ (Legacy)
77+
```php
78+
// Forms, Actions & Tables
79+
use SolutionForest\FilamentPanzoom\Components\PanZoom;
80+
81+
public static function form(Form $form): Form
82+
{
83+
return $form->schema([
84+
PanZoom::make('image_preview')
85+
->imageUrl(fn ($record) => $record?->image_url)
86+
->label('Image Preview')
87+
->columnSpanFull(),
88+
]);
89+
}
90+
91+
// Infolists
92+
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
93+
94+
public function infolist(Infolist $infolist): Infolist
95+
{
96+
return $infolist->schema([
97+
PanZoomEntry::make('image_preview')
98+
->imageUrl(fn ($record) => $record?->image_url)
99+
->label('Image Preview'),
100+
]);
101+
}
102+
```
103+
104+
#### Filament 4.0+ (Current)
105+
```php
106+
// Forms - Uses Schemas
107+
use SolutionForest\FilamentPanzoom\Components\PanZoom;
108+
109+
public static function configure(Schema $schema): Schema
110+
{
111+
return $schema->components([
112+
PanZoom::make('image_preview')
113+
->imageUrl(fn ($record) => $record?->image_url),
114+
// Note: label() and columnSpanFull() methods not available in 4.0+
115+
]);
116+
}
117+
118+
// Infolists - Uses Schemas
119+
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
120+
121+
public static function configure(Schema $schema): Schema
122+
{
123+
return $schema->components([
124+
PanZoomEntry::make('image_preview')
125+
->imageUrl(fn ($record) => $record?->image_url),
126+
]);
127+
}
128+
```
129+
71130
### In Blade Views
72131

73-
You can use the component directly in any Blade view:
132+
You can use the component directly in any Blade view (works in both 3.0+ and 4.0+):
74133

75134
```blade
76135
@include('filament-panzoom::filament-panzoom', [
@@ -79,41 +138,43 @@ You can use the component directly in any Blade view:
79138
])
80139
```
81140

82-
### Usage
141+
### Component Selection Guide
83142

84143
**⚠️ Important: Choose the correct component for your context!**
85144

86-
Filament requires different component base classes for different contexts:
87-
88-
**For Forms, Actions & Tables:**
89-
```php
90-
use SolutionForest\FilamentPanzoom\Components\PanZoom;
91-
92-
PanZoom::make('image_viewer')
93-
->imageUrl(fn ($record) => $record?->image_url)
94-
->columnSpanFull(),
95-
```
145+
| Context | Component | Import |
146+
|---------|-----------|--------|
147+
| Forms (3.0+) | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
148+
| Forms (4.0+) | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
149+
| Actions | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
150+
| Tables | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
151+
| Infolists (3.0+) | `PanZoomEntry` | `use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;` |
152+
| Infolists (4.0+) | `PanZoomEntry` | `use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;` |
96153

97-
**For Infolists:**
98-
```php
99-
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
154+
> **Why two components?** Filament has separate component hierarchies for Forms and Infolists. Using the wrong one will cause a TypeError.
100155
101-
PanZoomEntry::make('image_viewer')
102-
->imageUrl(fn ($record) => $record?->image_url)
103-
->imageId(fn ($record) => 'receipt-' . $record->id),
104-
```
156+
### Key Differences: Filament 3.0+ vs 4.0+
105157

106-
> **Why two components?** Filament has separate component hierarchies for Forms (`Filament\Forms\Components\Component`) and Infolists (`Filament\Infolists\Components\Component`). Using the wrong one will cause a TypeError.
158+
| Feature | Filament 3.0+ | Filament 4.0+ |
159+
|---------|---------------|---------------|
160+
| **Forms Structure** | `form(Form $form): Form` | `configure(Schema $schema): Schema` |
161+
| **Infolists Structure** | `infolist(Infolist $infolist): Infolist` | `configure(Schema $schema): Schema` |
162+
| **Available Methods** | `label()`, `columnSpanFull()`, etc. | Limited methods (Schemas-based) |
163+
| **Component Base** | `Filament\Forms\Components\Component` | `Filament\Schemas\Components\Component` |
164+
| **Auto-detection** | ✅ Yes | ✅ Yes |
107165

108166
### Usage Examples
109167

168+
#### Filament 3.0+ Examples
169+
110170
**In Forms:**
111171
```php
112172
public static function form(Form $form): Form
113173
{
114174
return $form->schema([
115175
PanZoom::make('image_preview')
116176
->imageUrl(fn ($record) => $record?->image_url)
177+
->label('Image Preview')
117178
->columnSpanFull(),
118179
]);
119180
}
@@ -128,6 +189,7 @@ public function infolist(Infolist $infolist): Infolist
128189
return $infolist->schema([
129190
PanZoomEntry::make('receipt_image')
130191
->imageUrl(fn ($record) => asset('storage/' . $record->image_path))
192+
->label('Receipt Image')
131193
->imageId(fn ($record) => 'receipt-' . $record->id),
132194
]);
133195
}
@@ -141,7 +203,8 @@ public static function table(Table $table): Table
141203
Action::make('viewImage')
142204
->form([
143205
PanZoom::make('image_viewer')
144-
->imageUrl(fn ($record) => $record->image_url),
206+
->imageUrl(fn ($record) => $record->image_url)
207+
->label('Image Viewer'),
145208
])
146209
]);
147210
}
@@ -154,11 +217,66 @@ protected function getFormSchema(): array
154217
return [
155218
PanZoom::make('document_viewer')
156219
->imageUrl($this->imageUrl)
220+
->label('Document Viewer')
157221
->columnSpanFull(),
158222
];
159223
}
160224
```
161225

226+
#### Filament 4.0+ Examples
227+
228+
**In Forms (Schemas):**
229+
```php
230+
public static function configure(Schema $schema): Schema
231+
{
232+
return $schema->components([
233+
PanZoom::make('image_preview')
234+
->imageUrl(fn ($record) => $record?->image_url),
235+
// Note: label() and columnSpanFull() methods not available in 4.0+
236+
]);
237+
}
238+
```
239+
240+
**In Infolists (Schemas):**
241+
```php
242+
use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;
243+
244+
public static function configure(Schema $schema): Schema
245+
{
246+
return $schema->components([
247+
PanZoomEntry::make('receipt_image')
248+
->imageUrl(fn ($record) => asset('storage/' . $record->image_path))
249+
->imageId(fn ($record) => 'receipt-' . $record->id),
250+
]);
251+
}
252+
```
253+
254+
**In Table Actions:**
255+
```php
256+
public static function table(Table $table): Table
257+
{
258+
return $table->actions([
259+
Action::make('viewImage')
260+
->form([
261+
PanZoom::make('image_viewer')
262+
->imageUrl(fn ($record) => $record->image_url),
263+
])
264+
]);
265+
}
266+
```
267+
268+
**In Custom Pages:**
269+
```php
270+
protected function getFormSchema(): array
271+
{
272+
return [
273+
PanZoom::make('document_viewer')
274+
->imageUrl($this->imageUrl),
275+
// Note: columnSpanFull() method not available in 4.0+
276+
];
277+
}
278+
```
279+
162280
## Component Properties
163281

164282
The component accepts the following properties:
@@ -168,10 +286,15 @@ The component accepts the following properties:
168286
| `imageUrl` | string | Yes | The URL of the image to display |
169287
| `imageId` | string | Yes | Unique identifier for the component instance |
170288

289+
## Quick Tips
290+
291+
💡 **Pro Tip**: Double-click anywhere on the image to quickly toggle between fit-to-container view and 2x zoom for detailed inspection!
292+
171293
## Features
172294

173295
### Zoom Controls
174296
- **Mouse Wheel**: Scroll to zoom in/out
297+
- **Double-Click**: Double-click to toggle between fit-to-container and 2x zoom
175298
- **Zoom Buttons**: Click the + and - buttons in the control panel
176299
- **Zoom Range**: 0.5x to 5x magnification
177300

@@ -212,14 +335,35 @@ The component uses Tailwind CSS classes and is designed to work seamlessly with
212335
**Fatal Error: Class was composed with trait conflicts**
213336
- ✅ Fixed in v1.2.1+ - update your package
214337

338+
**Method not found: label() or columnSpanFull() in Filament 4.0+**
339+
- ❌ These methods aren't available in Filament 4.0+ Schemas
340+
- ✅ Remove these method calls or use Filament 3.0+ syntax
341+
342+
**Undefined type 'Filament\Schemas\Components\Component'**
343+
- ❌ Linter error in Filament 3.0+ environment
344+
- ✅ This is expected - the package uses runtime detection for compatibility
345+
346+
### Version-Specific Issues
347+
348+
#### Filament 3.0+
349+
- ✅ All methods available (`label()`, `columnSpanFull()`, etc.)
350+
- ✅ Traditional Forms/Infolists structure
351+
352+
#### Filament 4.0+
353+
- ⚠️ Limited methods available (Schemas-based)
354+
- ⚠️ Different structure (`configure(Schema $schema)`)
355+
- ✅ Automatic compatibility detection
356+
215357
### Quick Reference
216358

217359
| Context | Component | Import |
218360
|---------|-----------|--------|
219-
| Forms | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
361+
| Forms (3.0+) | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
362+
| Forms (4.0+) | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
220363
| Actions | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
221364
| Tables | `PanZoom` | `use SolutionForest\FilamentPanzoom\Components\PanZoom;` |
222-
| Infolists | `PanZoomEntry` | `use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;` |
365+
| Infolists (3.0+) | `PanZoomEntry` | `use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;` |
366+
| Infolists (4.0+) | `PanZoomEntry` | `use SolutionForest\FilamentPanzoom\Infolists\Components\PanZoomEntry;` |
223367

224368
## Browser Support
225369

0 commit comments

Comments
 (0)