Skip to content

Commit

Permalink
Merge pull request #16 from dissto/allow-htmlable
Browse files Browse the repository at this point in the history
Proposal: Allow to pass an `Htmlable` to the view getting rid of unescaped output
  • Loading branch information
CodeWithDennis authored Oct 4, 2024
2 parents 8e70442 + efb435e commit 419cfa6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 14 deletions.
22 changes: 14 additions & 8 deletions resources/views/components/simple-alert.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,20 @@ class="h-5 w-5 text-custom-400"
</div>
@endif
<div class="ml-3 flex-1 md:flex md:justify-between">
<div>
<p class="text-sm font-medium text-custom-800 dark:text-white">
{!! $title !!}
</p>
<p class="text-sm text-custom-700 dark:text-white">
{!! $description !!}
</p>
</div>
@if($title || $description)
<div>
@if($title)
<p class="text-sm font-medium text-custom-800 dark:text-white">
{{ $title }}
</p>
@endif
@if($description)
<p class="text-sm text-custom-700 dark:text-white">
{{ $description }}
</p>
@endif
</div>
@endif
@if($link)
<p class="mt-3 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
7 changes: 4 additions & 3 deletions src/Components/Concerns/HasDescription.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
namespace CodeWithDennis\SimpleAlert\Components\Concerns;

use Closure;
use Illuminate\Contracts\Support\Htmlable;

trait HasDescription
{
protected Closure|string|null $description = null;
protected string | Htmlable | Closure | null $description = null;

public function description(Closure|string|null $description): static
public function description(string | Htmlable | Closure | null $description): static
{
$this->description = $description;

return $this;
}

public function getDescription(): ?string
public function getDescription(): string | Htmlable | null
{
return $this->evaluate($this->description);
}
Expand Down
7 changes: 4 additions & 3 deletions src/Components/Concerns/HasTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
namespace CodeWithDennis\SimpleAlert\Components\Concerns;

use Closure;
use Illuminate\Contracts\Support\Htmlable;

trait HasTitle
{
protected Closure|string|null $title = null;
protected string | Htmlable | Closure | null $title = null;

public function title(Closure|string|null $title): static
public function title(string | Htmlable | Closure | null $title): static
{
$this->title = $title;

return $this;
}

public function getTitle(): ?string
public function getTitle(): string | Htmlable | null
{
return $this->evaluate($this->title);
}
Expand Down

0 comments on commit 419cfa6

Please sign in to comment.