1: <?php
2:
3: 4: 5: 6: 7: 8: 9: 10:
11:
12: namespace Chromabits\Nucleus\View\Bootstrap;
13:
14: use Chromabits\Nucleus\Support\Arr;
15: use Chromabits\Nucleus\View\Interfaces\RenderableInterface;
16: use Chromabits\Nucleus\View\Node;
17:
18: 19: 20: 21: 22: 23:
24: class Column extends Node
25: {
26: 27: 28:
29: protected $extraSmall;
30:
31: 32: 33:
34: protected $small;
35:
36: 37: 38:
39: protected $medium;
40:
41: 42: 43:
44: protected $large;
45:
46: 47: 48: 49: 50: 51:
52: public function __construct(
53: array $attributes,
54: $content
55: ) {
56: $classes = [];
57:
58: $this->extraSmall = (int) Arr::dotGet($attributes, 'extraSmall', 0);
59: $this->small = (int) Arr::dotGet($attributes, 'small', 0);
60: $this->medium = (int) Arr::dotGet($attributes, 'medium', 0);
61: $this->large = (int) Arr::dotGet($attributes, 'large', 0);
62:
63: if ($this->extraSmall > 0) {
64: $classes[] = 'col-xs-' . $this->extraSmall;
65: }
66:
67: if ($this->small > 0) {
68: $classes[] = 'col-sm-' . $this->small;
69: }
70:
71: if ($this->medium > 0) {
72: $classes[] = 'col-md-' . $this->medium;
73: }
74:
75: if ($this->large > 0) {
76: $classes[] = 'col-lg-' . $this->large;
77: }
78:
79: if (Arr::has($attributes, 'class')) {
80: $classes[] = $attributes['class'];
81: }
82:
83: $attributes['class'] = implode(' ', $classes);
84:
85: parent::__construct('div', $attributes, $content, false);
86: }
87: }
88: