-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for infolist components
- Loading branch information
Showing
4 changed files
with
130 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
{{ $getChildComponentContainer() }} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<div | ||
wire:ignore.self | ||
x-cloak | ||
{{ | ||
$attributes | ||
->merge([ | ||
'id' => $getId(), | ||
'wire:key' => "{$this->getId()}.{$getStatePath()}." . Accordions::class . '.container', | ||
], escape: false) | ||
->merge($getExtraAttributes(), escape: false) | ||
->merge($getExtraAlpineAttributes(), escape: false) | ||
->class([ | ||
'rounded-xl bg-white shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10', | ||
]) | ||
}} | ||
> | ||
|
||
@php | ||
$isIsolated = $isIsolated(); | ||
$getActiveAccordion = $getActiveAccordion(); | ||
@endphp | ||
|
||
<x-zeus-accordion::accordion :activeAccordion="$getActiveAccordion"> | ||
@foreach ($getChildComponentContainer()->getComponents() as $accordion) | ||
<x-zeus-accordion::accordion.item | ||
:label="$accordion->getLabel()" | ||
:icon="$accordion->getIcon()" | ||
:badge="$accordion->getBadge()" | ||
:badge-color="$accordion->getBadgeColor()" | ||
:isIsolated="$isIsolated" | ||
:activeAccordion="$getActiveAccordion"> | ||
{{ $accordion }} | ||
</x-zeus-accordion::accordion.item> | ||
@endforeach | ||
</x-zeus-accordion::accordion> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace LaraZeus\Accordion\Infolists; | ||
|
||
use Closure; | ||
use Filament\Infolists\Components\Component; | ||
use Filament\Support\Concerns\HasBadge; | ||
use Filament\Support\Concerns\HasIcon; | ||
use Illuminate\Support\Str; | ||
|
||
class Accordion extends Component | ||
{ | ||
use HasIcon; | ||
use HasBadge; | ||
|
||
protected string $view = 'zeus-accordion::infolists.accordion'; | ||
|
||
final public function __construct(string $label) | ||
{ | ||
$this->label($label); | ||
$this->id(Str::slug($label)); | ||
} | ||
|
||
public function getId(): string | ||
{ | ||
return $this->getContainer()->getParentComponent()->getId() . '-' . parent::getId() . '-accordion'; | ||
} | ||
|
||
public function getColumnsConfig(): array | ||
{ | ||
return $this->columns ?? $this->getContainer()->getColumnsConfig(); | ||
} | ||
|
||
public static function make(string | Closure | null $label = null): static | ||
{ | ||
$static = app(static::class, ['label' => $label]); | ||
$static->configure(); | ||
|
||
return $static; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<?php | ||
|
||
namespace LaraZeus\Accordion\Infolists; | ||
|
||
use Closure; | ||
use Filament\Infolists\Components\Component; | ||
use Filament\Support\Concerns; | ||
use LaraZeus\Accordion\Concerns\CanBeIsolated; | ||
|
||
class Accordions extends Component | ||
{ | ||
use CanBeIsolated; | ||
use Concerns\HasExtraAlpineAttributes; | ||
|
||
protected string $view = 'zeus-accordion::infolists.accordions'; | ||
|
||
protected int | Closure $activeAccordion = 1; | ||
|
||
final public function __construct(?string $label = null) | ||
{ | ||
$this->label($label); | ||
} | ||
|
||
public static function make(?string $label = null): static | ||
{ | ||
$static = app(static::class, ['label' => $label]); | ||
$static->configure(); | ||
|
||
return $static; | ||
} | ||
|
||
public function activeAccordion(int | Closure $activeAccordion): static | ||
{ | ||
$this->activeAccordion = $activeAccordion; | ||
|
||
return $this; | ||
} | ||
|
||
public function getActiveAccordion(): int | ||
{ | ||
return $this->evaluate($this->activeAccordion); | ||
} | ||
|
||
public function accordions(array | Closure $accordions): static | ||
{ | ||
$this->childComponents($accordions); | ||
|
||
return $this; | ||
} | ||
} |