From 089e9c1b68ad5eea723994c449fbd3715796e63b Mon Sep 17 00:00:00 2001 From: Zvonimir Lokmer Date: Tue, 30 Jan 2024 17:39:44 +0100 Subject: [PATCH] added support for infolist components --- resources/views/infolists/accordion.blade.php | 3 ++ .../views/infolists/accordions.blade.php | 36 +++++++++++++ src/Infolists/Accordion.php | 41 +++++++++++++++ src/Infolists/Accordions.php | 50 +++++++++++++++++++ 4 files changed, 130 insertions(+) create mode 100644 resources/views/infolists/accordion.blade.php create mode 100644 resources/views/infolists/accordions.blade.php create mode 100644 src/Infolists/Accordion.php create mode 100644 src/Infolists/Accordions.php diff --git a/resources/views/infolists/accordion.blade.php b/resources/views/infolists/accordion.blade.php new file mode 100644 index 0000000..d8b994f --- /dev/null +++ b/resources/views/infolists/accordion.blade.php @@ -0,0 +1,3 @@ +
+ {{ $getChildComponentContainer() }} +
diff --git a/resources/views/infolists/accordions.blade.php b/resources/views/infolists/accordions.blade.php new file mode 100644 index 0000000..1aed13e --- /dev/null +++ b/resources/views/infolists/accordions.blade.php @@ -0,0 +1,36 @@ +
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 + + + @foreach ($getChildComponentContainer()->getComponents() as $accordion) + + {{ $accordion }} + + @endforeach + +
diff --git a/src/Infolists/Accordion.php b/src/Infolists/Accordion.php new file mode 100644 index 0000000..7bee43d --- /dev/null +++ b/src/Infolists/Accordion.php @@ -0,0 +1,41 @@ +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; + } +} diff --git a/src/Infolists/Accordions.php b/src/Infolists/Accordions.php new file mode 100644 index 0000000..6b4eb2c --- /dev/null +++ b/src/Infolists/Accordions.php @@ -0,0 +1,50 @@ +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; + } +}