Skip to content

Commit

Permalink
Merge pull request #21 from dissto/add-border
Browse files Browse the repository at this point in the history
Add border
  • Loading branch information
CodeWithDennis authored Oct 6, 2024
2 parents ad9f340 + 7d9d3f6 commit a01afe0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 2 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 @@ -7,5 +7,6 @@
:link="$getLink()"
:link-label="$getLinkLabel()"
:link-blank="$getLinkBlank()"
: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>
8 changes: 6 additions & 2 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 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 a01afe0

Please sign in to comment.