GrafiteInc/Html

View on GitHub
src/Components/Offcanvas.php

Summary

Maintainability
A
45 mins
Test Coverage
<?php

namespace Grafite\Html\Components;

use Grafite\Html\Components\HtmlComponent;
use Grafite\Html\Tags\OffCanvas as OffCanvasTag;

class Offcanvas extends HtmlComponent
{
    public $title;
    public $cssClass;
    public $id;
    public $position;
    public $width;
    public $backdrop;

    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function __construct(
        $title = null,
        $cssClass = null,
        $id = null,
        $width = null,
        $backdrop = 'true',
        $position = 'end'
    ) {
        $this->title = $title;
        $this->cssClass = $cssClass;
        $this->position = $position;
        $this->backdrop = $backdrop;
        $this->width = $width;
        $this->id = $id;
    }

    /**
     * Get the view / contents that represent the component.
     *
     * @return \Illuminate\Contracts\View\View|\Closure|string
     */
    public function render()
    {
        return OffCanvasTag::make()
            ->text($this->title)
            ->css($this->cssClass)
            ->id($this->id)
            ->position($this->position)
            ->width($this->width)
            ->backdrop($this->backdrop)
            ->render();
    }
}