Skip to content

Commit b26564b

Browse files
authored
Merge pull request #5 from brkcvn/master
Bugfix solved in tailwind left menu
2 parents f641ef5 + aafec73 commit b26564b

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

src/Presenters/Admin/Tailwind.php

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,11 @@ public function getCloseTagWrapper()
3434
*/
3535
public function getMenuWithoutDropdownWrapper($item)
3636
{
37-
return '<li class="group relative mb-2.5">
38-
<a class="flex items-center text-secondary" href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>
39-
<div class="w-8 h-8 flex items-center justify-center">
37+
return '<li class="group relative pb-2.5">
38+
<a class="flex items-center text-secondary ' . $this->getActiveState($item) . '" href="' . $item->getUrl() . '" ' . $item->getAttributes() . '>
4039
' . $this->getIcon($item) . '
41-
</div>
4240
<span class="text-sm ml-2 hover:font-bold">' . $item->title . '</span>
43-
<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>
41+
<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>
4442
</a>
4543
</li>'
4644
. PHP_EOL;
@@ -49,9 +47,9 @@ public function getMenuWithoutDropdownWrapper($item)
4947
/**
5048
* {@inheritdoc }.
5149
*/
52-
public function getActiveState($item, $state = '' )
50+
public function getActiveState($item, $state = 'active-menu' )
5351
{
54-
return $item->isActive() ? $state : '-outline';
52+
return $item->isActive() ? $state : '';
5553
}
5654

5755
/**
@@ -105,12 +103,12 @@ public function getMenuWithDropDownWrapper($item)
105103

106104
return '
107105
<details '. $this->getActiveStateOnChild($item) .'>
108-
<summary class="relative mb-2.5 flex mt-2 items-center cursor-pointer text-secondary" href="#navbar-' . $id . '">
106+
<summary class="relative pb-2.5 flex items-center cursor-pointer text-secondary" href="#navbar-' . $id . '">
109107
' . $this->getIcon($item) . '
110108
<span class="text-sm font-normal ml-2">' . $item->title . '</span>
111109
' . $this->getChevron($item) . '
112110
</summary>
113-
<div class="mt-2 ml-8 " id="navbar-' . $id . '">
111+
<div class="mt-2 ml-8 menu__submenu" id="navbar-' . $id . '">
114112
<ul class="relative pb-2.5">
115113
' . $this->getChildMenuItems($item) . '
116114
</ul>
@@ -130,27 +128,40 @@ public function getMultiLevelDropdownWrapper($item)
130128
{
131129
$id = Str::slug($item->title);
132130

133-
return '<li class="nav-item">
134-
<a class="nav-link' . $this->getActiveState($item) . '" href="#navbar-' . $id . '" data-toggle="collapse" role="button" aria-expanded="false" aria-controls="navbar-' . $id . '">
135-
' . $item->getIcon() . '
136-
<span class="nav-link-text">' . $item->title . '</span>
137-
</a>
138-
<div class="collapse' . $this->getShowStateOnChild($item) . '" id="navbar-' . $id . '">
139-
<ul class="nav nav-sm flex-column">
140-
' . $this->getChildMenuItems($item) . '
141-
</ul>
142-
</div>
143-
</li>'
131+
return '<li class="group relative pb-2.5">
132+
<a class="flex items-center text-secondary' . $this->getActiveState($item) . '" href="#navbar-' . $id . '" aria-controls="navbar-' . $id . '">
133+
' . $this->getIcon($item) . '
134+
<span class="text-sm ml-2 hover:font-bold">' . $item->title . '</span>
135+
<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>
136+
</a>
137+
<div class="mt-2 ml-8 menu__submenu' . $this->getShowStateOnChild($item) . '" id="navbar-' . $id . '">
138+
<ul class="relative pb-2.5">
139+
' . $this->getChildMenuItems($item) . '
140+
</ul>
141+
</div>
142+
</li>'
144143
. PHP_EOL;
145144
}
146145

146+
public function iconState($item, $state = '')
147+
{
148+
return $item->isActive() ? $state : '-outline';
149+
}
150+
151+
public function iconChildState($item, $state = '')
152+
{
153+
return $item->hasActiveOnChild() ? $state : '-outline';
154+
}
155+
147156
public function getIcon($item)
148157
{
149-
$state = $this->iconState($item);
158+
$state = empty($item->getChilds()) ? $this->iconState($item) : $this->iconChildState($item);
150159

151-
return '<div class="w-8 h-8 flex colour-secondary items-center justify-center">
152-
<ion-icon class="w-5 h-5 text-secondary colour-secondary ' . $item->icon . '" name="' . $item->icon . $state .'"></ion-icon>
153-
</div>'. PHP_EOL;
160+
if ($item->icon !== null && $item->icon !== '') {
161+
return '<div class="w-8 h-8 flex colour-secondary items-center justify-center">
162+
<ion-icon class="w-5 h-5 text-secondary colour-secondary ' . $item->icon . '" name="' . $item->icon . $state .'"></ion-icon>
163+
</div>'. PHP_EOL;
164+
}
154165
}
155166

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

163-
public function iconState($item, $state = '')
164-
{
165-
return $item->hasActiveOnChild() ? $state : '-outline';
166-
}
167-
168174
public function chevronState($item, $state = '-up')
169175
{
170176
return $item->hasActiveOnChild() ? $state : '-down';

0 commit comments

Comments
 (0)