mirror of
https://github.com/filamentphp/filament.git
synced 2026-09-24 15:42:09 +08:00
Misc. tweaks
This commit is contained in:
@@ -19,14 +19,14 @@
|
||||
@if ($user->avatar && $deleteMethod)
|
||||
<button type="button"
|
||||
wire:click="{{ $deleteMethod }}"
|
||||
class="absolute top-0 right-0 w-4 h-4 rounded-full bg-gray-800 text-white flex items-center justify-center hover:bg-red-700">
|
||||
class="absolute top-0 right-0 w-4 h-4 rounded-full bg-gray-800 text-white flex items-center justify-center hover:bg-red-700 transition-colors duration-200">
|
||||
<span class="sr-only">{{ __('Delete Avatar') }}</span>
|
||||
<x-heroicon-o-x class="w-3 h-3" />
|
||||
</button>
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex-grow relative">
|
||||
<label class="btn" for="{{ $id ?? $model }}">{{ __('Change') }}</label>
|
||||
<label class="btn" for="{{ $id ?? $model }}">{{ __($buttonLabel) }}</label>
|
||||
<input type="file"
|
||||
{{ $modelDirective }}="{{ $model }}"
|
||||
value="{{ $value }}"
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace Filament\Fields;
|
||||
class Avatar extends Field {
|
||||
public $avatar;
|
||||
public $user;
|
||||
public $buttonLabel = 'Change';
|
||||
public $deleteMethod;
|
||||
public $size = 64;
|
||||
|
||||
@@ -26,6 +27,15 @@ class Avatar extends Field {
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
public function buttonLabel(string $label): self
|
||||
{
|
||||
$this->buttonLabel = $label;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return static
|
||||
*/
|
||||
|
||||
@@ -101,14 +101,13 @@ class Profile extends Component
|
||||
->extraAttributes([
|
||||
'required' => 'true',
|
||||
'autocomplete' => 'email',
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
]),
|
||||
Avatar::make('avatar')
|
||||
->label('User Photo')
|
||||
->avatar($this->avatar)
|
||||
->user($this->user)
|
||||
->deleteMethod('deleteAvatar')
|
||||
->hint(__('Optional')),
|
||||
->deleteMethod('deleteAvatar'),
|
||||
Fieldset::make('Update Password')
|
||||
->fields([
|
||||
Text::make('password')
|
||||
|
||||
Reference in New Issue
Block a user