Skip to content

Commit

Permalink
Merge pull request #27 from breaktag/master
Browse files Browse the repository at this point in the history
Add support for item level classes and 'open in a new tab' feature
  • Loading branch information
patrickbrouwers authored Mar 22, 2017
2 parents e93edfa + 13e5aeb commit 27342bb
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 2 deletions.
4 changes: 2 additions & 2 deletions resources/views/item.blade.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<li class="@if($active)active @endif @if($item->hasItems()) treeview @endif clearfix">
<a href="{{ $item->getUrl() }}" @if(count($appends) > 0)class="hasAppend"@endif>
<li class="@if($item->getItemClass()){{ $item->getItemClass() }}@endif @if($active)active@endif @if($item->hasItems())treeview@endif clearfix">
<a href="{{ $item->getUrl() }}" class="@if(count($appends) > 0) hasAppend @endif" @if($item->getNewTab())target="_blank"@endif>
<i class="{{ $item->getIcon() }}"></i>
<span>{{ $item->getName() }}</span>

Expand Down
50 changes: 50 additions & 0 deletions src/Domain/DefaultItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@ class DefaultItem implements Item, Serializable
*/
protected $activeWhen = false;

/**
* @var bool
*/
protected $newTab = false;

/**
* @var string
*/
protected $itemClass = '';

/**
* @var Collection|Badge[]
*/
Expand Down Expand Up @@ -289,4 +299,44 @@ public function getActiveWhen()
{
return $this->activeWhen;
}

/**
* @param bool $newTab
*
* @return $this
*/
public function isNewTab($newTab = true)
{
$this->newTab = $newTab;

return $this;
}

/**
* @return bool
*/
public function getNewTab()
{
return $this->newTab;
}

/**
* @param string $itemClass
*
* @return $this
*/
public function setItemClass($itemClass)
{
$this->itemClass = $itemClass;

return $this;
}

/**
* @return string
*/
public function getItemClass()
{
return $this->itemClass;
}
}
12 changes: 12 additions & 0 deletions src/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,4 +125,16 @@ public function isActiveWhen($path);
* @return string
*/
public function getActiveWhen();

/**
* @param string $newTab
*
* @return $this
*/
public function isNewTab($newTab);

/**
* @return bool
*/
public function getNewTab();
}

0 comments on commit 27342bb

Please sign in to comment.