Skip to content

Commit

Permalink
Merge branch 'main' into add-actions-to-entry
Browse files Browse the repository at this point in the history
  • Loading branch information
dissto authored Oct 6, 2024
2 parents 7aa5ab1 + 63ab6d6 commit 769299d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,16 @@ SimpleAlert::make('example')
->description('This is the description')
```

### Border

You can add a border to the alert by using the `border` method.

```php
use CodeWithDennis\SimpleAlert\Components\Infolists\SimpleAlert;

SimpleAlert::make('example')
->border(true)
```
### Actions

You can also add actions to the alert by using the `actions` method. All regular action features are supported.
Expand Down
1 change: 1 addition & 0 deletions resources/views/components/simple-alert-entry.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
:link-label="$getLinkLabel()"
:link-blank="$getLinkBlank()"
:actions="$getActions()"
:border="$getBorder()"
/>
</x-dynamic-component>
1 change: 1 addition & 0 deletions resources/views/components/simple-alert-field.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
:link-label="$getLinkLabel()"
:link-blank="$getLinkBlank()"
:actions="$getActions()"
:border="$getBorder()"
/>
</x-dynamic-component>
10 changes: 7 additions & 3 deletions resources/views/components/simple-alert.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
@props([
'actions' => null,
'border' => false,
'color' => null,
'description' => null,
'icon' => null,
Expand All @@ -13,13 +14,16 @@
use function Filament\Support\get_color_css_variables;
$colors = \Illuminate\Support\Arr::toCssStyles([
get_color_css_variables($color, shades: [50, 400, 500, 600, 700, 800]),
get_color_css_variables($color, shades: [50, 100, 400, 500, 600, 700, 800]),
]);
@endphp

<div
x-data="{}"
class="filament-simple-alert rounded-md bg-custom-50 p-4 dark:bg-gray-900 dark:ring-white/10"
@class([
'filament-simple-alert rounded-md bg-custom-50 p-4 dark:bg-gray-900 ',
'ring-1 ring-custom-100 dark:ring-white/10' => $border,
])
style="{{ $colors }}">
<div class="flex">
@if($icon)
Expand All @@ -46,7 +50,7 @@ class="h-5 w-5 text-custom-400"
</div>
@endif
@if($link || $actions)
<div class="flex gap-x-3 items-center">
<div class="flex gap-x-3 items-center whitespace-nowrap">
@if($link)
<p class="text-sm md:ml-6 md:mt-0 self-center">
<a href="{{ $link }}" {{ $linkBlank ? 'target="_blank"' : '' }} class="whitespace-nowrap font-medium text-custom-400 hover:text-custom-500">
Expand Down
22 changes: 22 additions & 0 deletions src/Components/Concerns/HasBorder.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace CodeWithDennis\SimpleAlert\Components\Concerns;

use Closure;

trait HasBorder
{
protected Closure|bool $border = false;

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

return $this;
}

public function getBorder(): bool
{
return $this->evaluate($this->border);
}
}
2 changes: 2 additions & 0 deletions src/Components/Forms/SimpleAlert.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace CodeWithDennis\SimpleAlert\Components\Forms;

use Closure;
use CodeWithDennis\SimpleAlert\Components\Concerns\HasBorder;
use CodeWithDennis\SimpleAlert\Components\Concerns\HasColor;
use CodeWithDennis\SimpleAlert\Components\Concerns\HasDescription;
use CodeWithDennis\SimpleAlert\Components\Concerns\HasIcon;
Expand All @@ -13,6 +14,7 @@

class SimpleAlert extends Field
{
use HasBorder;
use HasColor;
use HasDescription;
use HasIcon;
Expand Down

0 comments on commit 769299d

Please sign in to comment.