Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: update styling to match avatar size #43

Merged
merged 1 commit into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,23 @@ public function panel(Panel $panel): Panel
}
```

### Appearance

By default, the Quick Create button will be fully rounded if you would like to have a more square button you can disable the rounding with the `rounded()` method.

```php
use Awcodes\FilamentQuickCreate\QuickCreatePlugin;

public function panel(Panel $panel): Panel
{
return $panel
->plugins([
QuickCreatePlugin::make()
->rounded(false),
])
}
```

### Slide Overs

By default, Quick Create will render simple resources in a standard modal. If you would like to render them in a slide over instead you may use the `slideOver()` modifier to do so.
Expand Down
6 changes: 5 additions & 1 deletion resources/views/components/create-menu.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
<x-filament::dropdown placement="bottom-end">
<x-slot name="trigger">
<button
class="flex flex-shrink-0 w-9 h-9 rounded-full bg-gray-100 items-center justify-center text-primary-500 hover:text-primary-900 dark:bg-gray-800 hover:bg-primary-500 dark:hover:bg-primary-500"
@class([
'flex flex-shrink-0 w-8 h-8 bg-gray-100 items-center justify-center text-primary-500 hover:text-primary-900 dark:bg-gray-800 hover:bg-primary-500 dark:hover:bg-primary-500',
'rounded-full' => $rounded,
'rounded-md' => ! $rounded,
])
aria-label="{{ __('filament-quick-create::quick-create.button_label') }}"
>
<x-filament::icon
Expand Down
3 changes: 3 additions & 0 deletions src/Components/QuickCreateMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,15 @@ class QuickCreateMenu extends Component implements HasForms, HasActions

public array $resources = [];

public ?bool $rounded = null;

/**
* @throws Exception
*/
public function mount(): void
{
$this->resources = QuickCreatePlugin::get()->getResources();
$this->rounded = QuickCreatePlugin::get()->isRounded();
}

/**
Expand Down
14 changes: 14 additions & 0 deletions src/QuickCreatePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ class QuickCreatePlugin implements Plugin

protected bool | Closure $hidden = false;

protected bool | Closure | null $rounded = null;

public function boot(Panel $panel): void
{
Livewire::component('quick-create-menu', Components\QuickCreateMenu::class);
Expand All @@ -50,6 +52,13 @@ public function includes(array $resources): static
return $this;
}

public function rounded(bool | Closure $condition = true): static
{
$this->rounded = $condition;

return $this;
}

public static function get(): static
{
return filament(app(static::class)->getId());
Expand Down Expand Up @@ -123,6 +132,11 @@ public function isSortable(): bool
return $this->evaluate($this->sort);
}

public function isRounded(): bool
{
return $this->evaluate($this->rounded) ?? true;
}

public static function make(): static
{
return app(static::class);
Expand Down