Misc. tweaks

This commit is contained in:
Ryan Scherler
2020-12-19 18:49:10 -08:00
parent d96088f336
commit a1314bfab0
3 changed files with 15 additions and 6 deletions
+2 -2
View File
@@ -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 }}"
+10
View File
@@ -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
*/
+3 -4
View File
@@ -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')