Skip to content

Commit

Permalink
because of an optional backdrop
Browse files Browse the repository at this point in the history
  • Loading branch information
mlantz committed Sep 6, 2023
1 parent 3d83e53 commit 7288481
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Components/Offcanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class Offcanvas extends HtmlComponent
public $cssClass;
public $id;
public $position;
public $backdrop;

/**
* Create a new component instance.
Expand All @@ -21,11 +22,13 @@ public function __construct(
$title = null,
$cssClass = null,
$id = null,
$backdrop = 'true',
$position = 'end'
) {
$this->title = $title;
$this->cssClass = $cssClass;
$this->position = $position;
$this->backdrop = $backdrop;
$this->id = $id;
}

Expand All @@ -41,6 +44,7 @@ public function render()
->css($this->cssClass)
->id($this->id)
->position($this->position)
->backdrop($this->backdrop)
->render();
}
}
12 changes: 11 additions & 1 deletion src/Tags/OffCanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,33 @@ class OffCanvas extends HtmlComponent
{
public static $position;

public static $backdrop;

public static function position($position)
{
self::$position = $position;

return new static();
}

public static function backdrop($backdrop)
{
self::$backdrop = $backdrop;

return new static();
}

public static function process()
{
$css = self::$css ?? '';
$text = self::$text ?? '';
$position = self::$position ?? 'end';
$backdrop = self::$backdrop ?? 'true';
$id = self::$id ?? 'html_component_offcanvas_' . Str::uuid();


self::$html = <<<html
<div id="offCanvas_{$id}" class="offcanvas offcanvas-{$position}" ref="offcanvas-panel" tabindex="-1" aria-labelledby="offcanvasLabel_{$id}">
<div id="offCanvas_{$id}" data-bs-backdrop="{$backdrop}" class="offcanvas offcanvas-{$position}" ref="offcanvas-panel" tabindex="-1" aria-labelledby="offcanvasLabel_{$id}">
<div class="offcanvas-header">
<h5 id="offcanvasLabel_{$id}">{$text}</h5>
<button type="button" class="btn-close bg-secondary text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
Expand Down

0 comments on commit 7288481

Please sign in to comment.