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

Commit

Permalink
Merge pull request #103 from helsingborg-stad/feature/nav-dynamic-chi…
Browse files Browse the repository at this point in the history
…ldren

Dynamic child items
  • Loading branch information
silvergrund authored Apr 23, 2020
2 parents 0b16a68 + 8c66c23 commit fa45267
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/Component/Sidebar/Sidebar.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ public function init()
{
//Extract array for eazy access (fetch only)
extract($this->data);

if(isset($childItemsUrl)) {
$this->data['attributeList']['child-items-url'] = $childItemsUrl;
}
}
}
12 changes: 8 additions & 4 deletions src/Component/Sidebar/item.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,23 @@
{{$item['label']}}
</a>

@if (isset($item['children']))
@if ($item['children'])
@php
$rndId = uniqid();
@endphp
<div class="{{$baseClass}}__toggle"
js-toggle-trigger="{{$rndId}}"
@if(!isset($childItemsUrl))
js-toggle-trigger="{{$rndId}}"
@endif
aria-label="{{$item['ID']}}"
aria-pressed="false">

<div class="bar"></div>
<div class="bar"></div>
</div>

@include ('Sidebar.item', array('items' => $item['children'], 'appendID' => $rndId, 'top_level' => false))
@if(!isset($childItemsUrl))
@include ('Sidebar.item', array('items' => $item['children'], 'appendID' => $rndId, 'top_level' => false))
@endif
@endif
</div>
@endforeach
Expand Down

0 comments on commit fa45267

Please sign in to comment.