Skip to content

Commit

Permalink
Added ability to toggle active dropdown icon option
Browse files Browse the repository at this point in the history
  • Loading branch information
JKHarley committed Jul 17, 2023
1 parent 7bc6328 commit 2363075
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 1 deletion.
1 change: 1 addition & 0 deletions config/filament-trumbowyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
return [
'buttons' => [],
'tagClasses' => [],
'changeActiveDropdownIcon' => false,
];
15 changes: 14 additions & 1 deletion resources/views/trumbowyg.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
resetCss: true,
}
@if (!is_null($getButtons()))
options.btns = @json($getButtons())
@endif
Expand All @@ -64,6 +63,20 @@
options.tagClasses = @json(config('filament-trumbowyg.tagClasses'));
@endif
@if (!is_null($getChangeActiveDropdownIcon()))
options.changeActiveDropdownIcon = @json($getChangeActiveDropdownIcon());
@endif
@if (
is_null($getChangeActiveDropdownIcon()) &&
!is_null(config('filament-trumbowyg.changeActiveDropdownIcon')) &&
config('filament-trumbowyg.changeActiveDropdownIcon')
)
options.changeActiveDropdownIcon = @json(config('filament-trumbowyg.changeActiveDropdownIcon'));
@endif
console.log(options)
$(id).trumbowyg(options);
if (window.livewire.data) {
Expand Down
2 changes: 2 additions & 0 deletions src/Trumbowyg.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace JKHarley\FilamentTrumbowyg;

use Filament\Forms\Components\Concerns\HasPlaceholder;
use JKHarley\FilamentTrumbowyg\traits\HasChangeActiveDropdownIcon;
use JKHarley\FilamentTrumbowyg\traits\HasButtons;
use JKHarley\FilamentTrumbowyg\traits\HasTagClasses;

Expand All @@ -11,6 +12,7 @@ class Trumbowyg extends \Filament\Forms\Components\Field
use HasPlaceholder;
use HasButtons;
use HasTagClasses;
use HasChangeActiveDropdownIcon;

protected string $view = 'filament-trumbowyg::trumbowyg';
}
22 changes: 22 additions & 0 deletions src/traits/HasChangeActiveDropdownIcon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace JKHarley\FilamentTrumbowyg\traits;

use Closure;

trait HasChangeActiveDropdownIcon
{
protected bool|Closure|null $changeActiveDropdownIcon = null;

public function changeActiveDropdownIcon(bool|Closure|null $changeActiveDropdownIcon): static
{
$this->changeActiveDropdownIcon = $changeActiveDropdownIcon;

return $this;
}

public function getChangeActiveDropdownIcon(): ?bool
{
return $this->evaluate($this->changeActiveDropdownIcon);
}
}

0 comments on commit 2363075

Please sign in to comment.