diff --git a/app/View/Page/Modal.php b/app/View/Page/Modal.php new file mode 100644 index 00000000..072ff59f --- /dev/null +++ b/app/View/Page/Modal.php @@ -0,0 +1,101 @@ +component = $component; + $this->props = $props; + $this->size = $size; + $this->title = $title; + $this->key = md5(json_encode(['component' => $component, 'props' => $props])); + $this->actions = $this->parseActions($actions); + } + + public function parseActions(array $actions): array + { + return collect($actions)->map(function ($action) { + if ($action === 'closeable') { + return ['event' => 'closeModal', 'icon' => 'close', 'label' => 'Schließen']; + } + + if ($action === 'storeable') { + return ['event' => 'onStoreFromModal', 'icon' => 'save', 'label' => 'Speichern']; + } + + return $action; + })->toArray(); + } + + #[On('closeModal')] + public function onCloseModal(): void + { + $this->reset(); + } + + public function sizeClass(): string + { + if ($this->size === 'lg') { + return 'max-w-lg'; + } + + if ($this->size === 'xl') { + return 'max-w-xl'; + } + + return ''; + } + + public function render() + { + return <<<'HTML' +