Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit cd28b40

Browse files
author
Eric Rosenborg
committed
Squashed commit of the following:
commit 895e246 Author: Muckbuck <rosenborg.eric@gmail.com> Date: Mon Jun 8 14:31:41 2020 +0200 Rework of Register and Init classes to work with reworked BladeEngine… (#112) * Rework of Register and Init classes to work with reworked BladeEngine wrapper * Updated namespaces * Wrap printing of error in pre tags Co-authored-by: Eric Rosenborg <eric.rosenborg@hiq.se> commit 1bd6f79 Author: Alexander Boman Skoug <39676080+alexanderbomanskoug2@users.noreply.github.com> Date: Mon Jun 8 14:14:34 2020 +0200 Feature/navbar slot fix (#113) * Fixed slot for navbar * fixed slot commit f8048b8 Author: Alexander Boman Skoug <39676080+alexanderbomanskoug2@users.noreply.github.com> Date: Mon Jun 8 13:47:42 2020 +0200 Wip/navbar overflow fix (#109) * wip * Navbar Overflow Handling - add check if to expand sidebar on load - add slot to navbar commit 51aac96 Author: Muckbuck <rosenborg.eric@gmail.com> Date: Mon Jun 8 13:47:13 2020 +0200 Tags in cards (#111) Add configuration option to add an array of tags to a card. Co-authored-by: Eric Rosenborg <eric.rosenborg@hiq.se>
1 parent b0c1da9 commit cd28b40

File tree

8 files changed

+147
-77
lines changed

8 files changed

+147
-77
lines changed

src/Component/Card/card.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"collapsible": false,
1515
"hidden": "",
1616
"paddedImage": "",
17-
"color": "default"
17+
"color": "default",
18+
"tags": null
1819
},
1920
"description": {
2021
"image": "A url to a image.",

src/Component/Card/sub/footer.blade.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,11 @@
55
@endbutton
66
@endforeach
77
@endif
8+
9+
@if($tags)
10+
<div class="u-margin__top--2">
11+
@tags(['tags' => $tags,'classList' => ['u-margin__top--1']])
12+
@endtags
13+
</div>
14+
@endif
815
</div>

src/Component/Navbar/navbar.blade.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
</div>
3737
</a>
3838
@endforeach
39-
4039
</div>
4140

4241
@if ($expanded_menu)

src/Component/Sidebar/Sidebar.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,25 @@ public function init()
1313
if(isset($childItemsUrl)) {
1414
$this->data['attributeList']['child-items-url'] = $childItemsUrl;
1515
}
16+
17+
$this->data['top_items'] = $this->attributeItems($top_items);
18+
19+
if ($top_items & !$items) {
20+
$this->data['attributeList']['js-sidebar--overflow-only'] = "";
21+
}
22+
}
23+
24+
public function attributeItems($top_items)
25+
{
26+
foreach ($top_items as $key => $item)
27+
{
28+
$string = "";
29+
foreach ($item['attributeList'] as $key2 => $value)
30+
{
31+
$string = $string . $key2 . '=' . $value . ' ';
32+
}
33+
$top_items[$key]['attributeList'] = $string;
34+
}
35+
return $top_items;
1636
}
1737
}

src/Component/Sidebar/sidebar.blade.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
</div>
2525
@endif
2626

27+
@include ('Sidebar.top', array('items' => $top_items, 'appendID' => uniqid(), 'top_level' => true))
28+
2729
@include ('Sidebar.item', array('items' => $items, 'appendID' => uniqid(), 'top_level' => true))
2830
</nav>
2931

src/Component/Sidebar/top.blade.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<div class="{{$baseClass}}__subcontainer--top">
2+
@foreach ($top_items as $item)
3+
<div class="{{$baseClass}}__item">
4+
<a class="{{$baseClass}}__link" href="{{$item['href']}}" aria-label="{{$item['label']}}" item-active="{{isset($item['active']) ? "true" : "false"}}" {{ $item['attributeList'] }}>
5+
{{$item['label']}}
6+
</a>
7+
</div>
8+
@endforeach
9+
</div>
10+
11+
@divider(['size' => 'lg', 'style' => 'solid'])
12+
@enddivider

src/Init.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,26 @@
22

33
namespace BladeComponentLibrary;
44

5-
use HelsingborgStad\GlobalBladeEngine as Blade;
5+
use BladeComponentLibrary\Register;
6+
use HelsingborgStad\BladeEngineWrapper as Blade;
67

78
class Init {
8-
public function __construct(
9+
10+
public function __construct() {
11+
12+
$blade = new Blade();
913
$paths = array(
1014
'viewPaths' => array(),
1115
'controllerPaths' => array(),
1216
'internalComponentsPath' => array(),
13-
)
14-
) {
17+
);
1518
// Add view path to renderer
1619
// In this case all components, their controller and view path are located under the same folder structure.
1720
// This may differ in a Wordpress child implementation.
1821
$internalPaths = array(
1922
__DIR__ . DIRECTORY_SEPARATOR . 'Component' . DIRECTORY_SEPARATOR,
2023
);
21-
24+
2225
// Initialize all view paths so that this library is last
2326
$viewPaths = array_unique(
2427
array_merge($paths['viewPaths'], $internalPaths)
@@ -30,9 +33,13 @@ public function __construct(
3033
);
3134
}
3235
foreach ($viewPaths as $path) {
33-
Blade::addViewPath(rtrim($path, DIRECTORY_SEPARATOR));
36+
$blade->addViewPath(rtrim($path, DIRECTORY_SEPARATOR));
3437
}
3538

39+
$bladeInstance = $blade->instance();
40+
41+
$this->register = new Register($bladeInstance);
42+
3643
// Initialize all controller paths so that this library is last
3744
$controllerPaths = array_unique(
3845
array_merge($paths['controllerPaths'], $internalPaths)
@@ -44,11 +51,11 @@ public function __construct(
4451
);
4552
}
4653
foreach ($controllerPaths as $path) {
47-
Register::addControllerPath(
54+
$this->register->addControllerPath(
4855
rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR
4956
);
5057
}
51-
58+
5259
// Initialize all internal components paths so that this library is last
5360
$internalComponentsPath = array_unique(
5461
array_merge($paths['internalComponentsPath'], $internalPaths)
@@ -60,9 +67,16 @@ public function __construct(
6067
);
6168
}
6269
foreach ($internalComponentsPath as $path) {
63-
Register::registerInternalComponents(
70+
$this->register->registerInternalComponents(
6471
rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR
6572
);
6673
}
74+
75+
76+
}
77+
78+
public function getEngine()
79+
{
80+
return $this->register->getEngine();
6781
}
6882
}

0 commit comments

Comments
 (0)