Repository navigation
Expand file tree
/
Copy pathSlideOverComponent.php
More file actions
71 lines (65 loc) · 2.3 KB
/
Copy pathSlideOverComponent.php
File metadata and controls
71 lines (65 loc) · 2.3 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
<?php
declare(strict_types=1);
namespace NyonCode\WireCore\Modals\View;
use Illuminate\Contracts\View\View;
use Illuminate\View\Component;
use NyonCode\WireCore\Foundation\Support\ModalDefaults;
use NyonCode\WireCore\Modals\Support\SlideOverStyle;
/**
* Blade component: <x-wire-modals::slide-over>
*
* A panel that slides in from the edge of the screen.
*
* Usage:
* <x-wire-modals::slide-over
* wire:model="showPanel"
* heading="User Details"
* position="right"
* width="md"
* >
* {{-- Panel body content --}}
* </x-wire-modals::slide-over>
*
* The consumer-facing tag; the framework itself renders the same shell via
* `@include('wire-core::modals.slide-over', ['style' => new SlideOverStyle(...), ...])`
* so the core renderer does not depend on this Blade component (Rule 5). All
* presentation/layout logic lives in {@see SlideOverStyle}.
*/
class SlideOverComponent extends Component
{
public function __construct(
public ?string $heading = null,
public ?string $description = null,
public ?string $width = null,
public string $position = 'right',
public ?string $maxHeight = null,
public ?bool $closeOnClickAway = null,
public ?bool $closeOnEscape = null,
public bool $stickyFooter = false,
public bool $stickyHeader = false,
public ?string $id = null,
public ?string $closeAction = null,
public bool $bottomSheetOnMobile = false,
public ?string $breakpoint = null,
public ?int $zIndex = null,
public ?string $openOn = null,
) {
// Unset attributes follow config('wire-core.modals') — see ModalDefaults.
$this->width ??= ModalDefaults::slideOverWidth();
$this->closeOnClickAway ??= ModalDefaults::closeOnClickAway();
$this->closeOnEscape ??= ModalDefaults::closeOnEscape();
}
public function style(): SlideOverStyle
{
return new SlideOverStyle(
width: $this->width ?? ModalDefaults::slideOverWidth(),
position: $this->position,
bottomSheetOnMobile: $this->bottomSheetOnMobile,
breakpoint: $this->breakpoint,
);
}
public function render(): View
{
return view('wire-core::modals.slide-over', ['style' => $this->style()]);
}
}