Repository navigation
Expand file tree
/
Copy pathModal.php
More file actions
91 lines (77 loc) · 2.43 KB
/
Copy pathModal.php
File metadata and controls
91 lines (77 loc) · 2.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
declare(strict_types=1);
namespace NyonCode\WireCore\Modals;
use NyonCode\WireCore\Foundation\Concerns\HasModalProperties;
use NyonCode\WireCore\Modals\Concerns\HasFooterActions;
use NyonCode\WireCore\Modals\Concerns\HasModalIcon;
use NyonCode\WireCore\Modals\Contracts\ModalContract;
/**
* General-purpose modal configuration.
*
* Used as a building block for action modals, form modals,
* and standalone modal dialogs. Not a Blade component itself —
* provides configuration that Blade view components consume.
*
* Usage:
* Modal::make()
* ->heading('Edit Record')
* ->description('Update the record details below.')
* ->width('lg')
* ->closeOnClickAway(false);
*
* @phpstan-consistent-constructor
*/
class Modal implements ModalContract
{
use HasFooterActions;
use HasModalIcon;
use HasModalProperties;
protected bool $fullScreenOnMobile = false;
protected ?string $mobileWidth = null;
public static function make(): static
{
return new static;
}
public function fullScreenOnMobile(bool $fullScreen = true): static
{
$this->fullScreenOnMobile = $fullScreen;
return $this;
}
public function mobileWidth(string $width): static
{
$this->mobileWidth = $width;
return $this;
}
public function isFullScreenOnMobile(): bool
{
return $this->fullScreenOnMobile;
}
public function getMobileWidth(): ?string
{
return $this->mobileWidth;
}
/**
* @return array<string, mixed>
*/
public function toArray(): array
{
return [
'id' => $this->getId(),
'heading' => $this->getHeading(),
'description' => $this->getDescription(),
'icon' => $this->getIcon(),
'iconColor' => $this->getIconColor(),
'color' => $this->getColor(),
'width' => $this->getWidth(),
'maxHeight' => $this->getMaxHeight(),
'closeOnClickAway' => $this->shouldCloseOnClickAway(),
'closeOnEscape' => $this->shouldCloseOnEscape(),
'fullScreenOnMobile' => $this->isFullScreenOnMobile(),
'mobileWidth' => $this->getMobileWidth(),
'submitLabel' => $this->getSubmitLabel(),
'cancelLabel' => $this->getCancelLabel(),
'stickyFooter' => $this->hasStickyFooter(),
'stickyHeader' => $this->hasStickyHeader(),
];
}
}