Skip to content

Commit

Permalink
Merge pull request #43 from awcodes/chore/styling-updates
Browse files Browse the repository at this point in the history
Chore: update styling to match avatar size
  • Loading branch information
awcodes authored Mar 1, 2024
2 parents 7daae99 + 73dc96f commit b82c207
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
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

0 comments on commit b82c207

Please sign in to comment.