summaryrefslogtreecommitdiffstats
path: root/vendor/ipl/web/src/Common/Card.php
blob: 434132cb3816b01bdffbdcc84f7f92b6b7899050 (plain)
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
<?php

namespace ipl\Web\Common;

use ipl\Html\BaseHtmlElement;
use ipl\Html\Html;

abstract class Card extends BaseHtmlElement
{
    protected $tag = 'section';

    abstract protected function assembleBody(BaseHtmlElement $body);

    abstract protected function assembleHeader(BaseHtmlElement $header);

    protected function assembleFooter(BaseHtmlElement $footer)
    {
    }

    protected function createBody()
    {
        $body = Html::tag('div', ['class' => 'card-body']);

        $this->assembleBody($body);

        return $body;
    }

    protected function createFooter()
    {
        $footer = Html::tag('div', ['class' => 'card-footer']);

        $this->assembleFooter($footer);

        if (! $footer->isEmpty()) {
            return $footer;
        }
    }

    protected function createHeader()
    {
        $header = Html::tag('div', ['class' => 'card-header']);

        $this->assembleHeader($header);

        return $header;
    }

    protected function assemble()
    {
        $this->addAttributes(['class' => 'card']);

        $this->add([
            $this->createHeader(),
            $this->createBody(),
            $this->createFooter()
        ]);
    }
}