Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
marco76tv committed Jun 7, 2024
1 parent 46db46f commit 78d609c
Showing 1 changed file with 8 additions and 45 deletions.
53 changes: 8 additions & 45 deletions Filament/Blocks/ImageSpatie.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@

namespace Modules\UI\Filament\Blocks;

use Filament\Forms;
use Filament\Forms\Components\Builder\Block;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\SpatieMediaLibraryFileUpload;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Contracts\HasForms;
Expand All @@ -27,22 +25,20 @@ public static function make(
Hidden::make('img_uuid')
->default(fn () => Str::uuid()->toString())
->formatStateUsing(fn ($state) => $state ?? Str::uuid()->toString())
->live(),
// ->required(),
// ->live()
,

SpatieMediaLibraryFileUpload::make('image')
->live()
->hiddenLabel()
// ->imagePreviewHeight('250')
->imagePreviewHeight('666')
// ->panelLayout('integrated')
->imageResizeMode('cover')
->panelAspectRatio('2:1')
// ->imageResizeMode('cover')
// ->panelAspectRatio('2:1')
->maxSize(102400)
->disk('local')
->image()
// ->imageEditor()
->preserveFilenames()
// ->columnSpanFull()
->openable()
->downloadable()
// ->rules(Rule::dimensions()->maxWidth(600)->maxHeight(800))
Expand All @@ -56,43 +52,10 @@ function (HasForms $livewire, SpatieMediaLibraryFileUpload $component, Temporary
->toMediaCollection($get('img_uuid'));
}
),
/*
Select::make('ratio')
->options(static::getRatios())
->afterStateHydrated(static fn ($state, $set) => $state || $set('ratio', '4-3')),
TextInput::make('alt')
->columnSpanFull(),
*/
TextInput::make('caption')
// ->columnSpanFull()
,

// Filament\Forms\Components\SpatieMediaLibraryFileUpload::whereCustomProperties does not exist.
// ->whereCustomProperties(fn(Forms\Get $get) => ['gallery_id' => $get('gallery_id')])

// ->customProperties(fn(Forms\Get $get) => ['gallery_id' => $get('gallery_id')]),

// Forms\Components\SpatieMediaLibraryFileUpload::make('media_id')
TextInput::make('caption'),
])
->columns('form' === $context ? 2 : 1);
}

public static function getRatios(): array
{
return [
'4-3' => '4/3',
'3-4' => '3/4',
'free' => 'free',
];
}

public static function getRatioClass(string $ratio): string
{
return match ($ratio) {
'4-3' => 'aspect-[4/3]',
'3-4' => 'aspect-[3/4]',
default => '',
};
->columns('form' === $context ? 2 : 1)
;
}
}

0 comments on commit 78d609c

Please sign in to comment.