Skip to content

Commit

Permalink
Merge pull request #5 from brkcvn/master
Browse files Browse the repository at this point in the history
Bugfix solved in tailwind left menu
  • Loading branch information
denisdulici authored Nov 10, 2021
2 parents f641ef5 + aafec73 commit b26564b
Showing 1 changed file with 35 additions and 29 deletions.
64 changes: 35 additions & 29 deletions src/Presenters/Admin/Tailwind.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,11 @@ public function getCloseTagWrapper()
*/
public function getMenuWithoutDropdownWrapper($item)
{
return '<li class="group relative mb-2.5">
<a class="flex items-center text-secondary" href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>
<div class="w-8 h-8 flex items-center justify-center">
return '<li class="group relative pb-2.5">
<a class="flex items-center text-secondary ' . $this->getActiveState($item) . '" href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>
' . $this->getIcon($item) . '
</div>
<span class="text-sm ml-2 hover:font-bold">' . $item->title . '</span>
<span class="bg-secondary absolute h-5 -right-5 rounded-tl-lg rounded-bl-lg opacity-0 group-hover:opacity-100 transition-all" style="width: 5px;" ></span>
<span class="bg-secondary absolute h-5 -right-5 rounded-tl-lg rounded-bl-lg opacity-0 group-hover:opacity-100 transition-all" style="width: 5px;"></span>
</a>
</li>'
. PHP_EOL;
Expand All @@ -49,9 +47,9 @@ public function getMenuWithoutDropdownWrapper($item)
/**
* {@inheritdoc }.
*/
public function getActiveState($item, $state = '' )
public function getActiveState($item, $state = 'active-menu' )
{
return $item->isActive() ? $state : '-outline';
return $item->isActive() ? $state : '';
}

/**
Expand Down Expand Up @@ -105,12 +103,12 @@ public function getMenuWithDropDownWrapper($item)

return '
<details '. $this->getActiveStateOnChild($item) .'>
<summary class="relative mb-2.5 flex mt-2 items-center cursor-pointer text-secondary" href="#navbar-' . $id . '">
<summary class="relative pb-2.5 flex items-center cursor-pointer text-secondary" href="#navbar-' . $id . '">
' . $this->getIcon($item) . '
<span class="text-sm font-normal ml-2">' . $item->title . '</span>
' . $this->getChevron($item) . '
</summary>
<div class="mt-2 ml-8 " id="navbar-' . $id . '">
<div class="mt-2 ml-8 menu__submenu" id="navbar-' . $id . '">
<ul class="relative pb-2.5">
' . $this->getChildMenuItems($item) . '
</ul>
Expand All @@ -130,27 +128,40 @@ public function getMultiLevelDropdownWrapper($item)
{
$id = Str::slug($item->title);

return '<li class="nav-item">
<a class="nav-link' . $this->getActiveState($item) . '" href="#navbar-' . $id . '" data-toggle="collapse" role="button" aria-expanded="false" aria-controls="navbar-' . $id . '">
' . $item->getIcon() . '
<span class="nav-link-text">' . $item->title . '</span>
</a>
<div class="collapse' . $this->getShowStateOnChild($item) . '" id="navbar-' . $id . '">
<ul class="nav nav-sm flex-column">
' . $this->getChildMenuItems($item) . '
</ul>
</div>
</li>'
return '<li class="group relative pb-2.5">
<a class="flex items-center text-secondary' . $this->getActiveState($item) . '" href="#navbar-' . $id . '" aria-controls="navbar-' . $id . '">
' . $this->getIcon($item) . '
<span class="text-sm ml-2 hover:font-bold">' . $item->title . '</span>
<span class="bg-secondary absolute h-5 -right-5 rounded-tl-lg rounded-bl-lg opacity-0 group-hover:opacity-100 transition-all" style="width: 5px;"></span>
</a>
<div class="mt-2 ml-8 menu__submenu' . $this->getShowStateOnChild($item) . '" id="navbar-' . $id . '">
<ul class="relative pb-2.5">
' . $this->getChildMenuItems($item) . '
</ul>
</div>
</li>'
. PHP_EOL;
}

public function iconState($item, $state = '')
{
return $item->isActive() ? $state : '-outline';
}

public function iconChildState($item, $state = '')
{
return $item->hasActiveOnChild() ? $state : '-outline';
}

public function getIcon($item)
{
$state = $this->iconState($item);
$state = empty($item->getChilds()) ? $this->iconState($item) : $this->iconChildState($item);

return '<div class="w-8 h-8 flex colour-secondary items-center justify-center">
<ion-icon class="w-5 h-5 text-secondary colour-secondary ' . $item->icon . '" name="' . $item->icon . $state .'"></ion-icon>
</div>'. PHP_EOL;
if ($item->icon !== null && $item->icon !== '') {
return '<div class="w-8 h-8 flex colour-secondary items-center justify-center">
<ion-icon class="w-5 h-5 text-secondary colour-secondary ' . $item->icon . '" name="' . $item->icon . $state .'"></ion-icon>
</div>'. PHP_EOL;
}
}

public function getChevron($item)
Expand All @@ -160,11 +171,6 @@ public function getChevron($item)
return '<ion-icon data-id="cash" name="chevron' . $state . '" class="absolute right-0"></ion-icon>'. PHP_EOL;
}

public function iconState($item, $state = '')
{
return $item->hasActiveOnChild() ? $state : '-outline';
}

public function chevronState($item, $state = '-up')
{
return $item->hasActiveOnChild() ? $state : '-down';
Expand Down

0 comments on commit b26564b

Please sign in to comment.