FEATURE: style menu

This commit adds some markup to sidebars in admin.
This commit is contained in:
Michal Kváček
2016-01-24 16:55:23 +01:00
parent 8a91a95a67
commit 5d7e535239
14 changed files with 228 additions and 99 deletions
@@ -0,0 +1,77 @@
<?php
namespace App\MenuPresenters;
use Pingpong\Menus\MenuItem;
use Pingpong\Menus\Presenters\Presenter;
class FoundationDrilldownMenuPresenter extends Presenter
{
/**
* {@inheritdoc }
*/
public function getOpenTagWrapper()
{
return PHP_EOL . '<ul class="vertical menu" data-drilldown>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getCloseTagWrapper()
{
return PHP_EOL . '</ul>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getMenuWithoutDropdownWrapper($item)
{
return '<li' . $this->getActiveState($item) . '><a href="' . $item->getUrl() . '">' . $item->getIcon() . ' ' . $item->title . '</a></li>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getActiveState(MenuItem $item)
{
$active = ' class="active"';
if (empty($item->getChilds())) {
// for direct menu input return if page is active
return \Request::is($item->getRequest()) ? $active : null;
} else {
// on nested menu inputs loop over children and in case any of them is active, mark active also root level
foreach ($item->getChilds() as $child) {
if ($this->getActiveState($child)) {
return $active;
}
}
}
return null;
}
/**
* {@inheritdoc }
*/
public function getDividerWrapper()
{
return '<li class="divider"></li>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getMenuWithDropDownWrapper($item)
{
$active = $this->getActiveState($item);
return '<li>
<a ' . $active . ' href="#">' . $item->getIcon() . ' ' . $item->title . '</a>
<ul class="vertical menu">
' . $this->getChildMenuItems($item) . '
</ul>
</li>' . PHP_EOL;;
}
}
@@ -0,0 +1,61 @@
<?php
namespace App\MenuPresenters;
use Pingpong\Menus\Presenters\Presenter;
class FoundationDropdownMenuPresenter extends Presenter
{
/**
* {@inheritdoc }
*/
public function getOpenTagWrapper()
{
return PHP_EOL . '<ul class="vertical dropdown menu" data-dropdown-menu>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getCloseTagWrapper()
{
return PHP_EOL . '</ul>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getMenuWithoutDropdownWrapper($item)
{
$link = '<a href="' . $item->getUrl() . '">' . $item->getIcon() . ' ' . $item->title . '</a>';
return '<li' . $this->getActiveState($item) . '>' . $link . '</li>'.PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getActiveState($item)
{
return \Request::is($item->getRequest()) || $item->hasActiveOnChild ? ' class="active"' : null;
}
/**
* {@inheritdoc }
*/
public function getDividerWrapper()
{
return '<li class="divider"></li>'.PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getMenuWithDropDownWrapper($item)
{
return '<li>
<a href="#">' . $item->getIcon() . ' ' . $item->title . '</a>
<ul class="vertical menu">
' . $this->getChildMenuItems($item) . '
</ul>
</li>' . PHP_EOL;;
}
}
@@ -0,0 +1,10 @@
<?php
namespace App\MenuPresenters;
class FoundationInitializedDropdownMenuPresenter extends FoundationDropdownMenuPresenter
{
public function getOpenTagWrapper()
{
return PHP_EOL . '<ul class="menu">' . PHP_EOL;
}
}
@@ -1,63 +0,0 @@
<?php
namespace App\MenuPresenters;
use Pingpong\Menus\Presenters\Presenter;
class FoundationMenuPresenter extends Presenter
{
/**
* {@inheritdoc }
*/
public function getOpenTagWrapper()
{
return PHP_EOL . '<ul class="vertical menu-bar icon-left">' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getCloseTagWrapper()
{
return PHP_EOL . '</ul>' . PHP_EOL;
}
/**
* {@inheritdoc }
*/
public function getMenuWithoutDropdownWrapper($item)
{
return '<li'.$this->getActiveState($item).'><a href="'. $item->getUrl() .'">'.$item->getIcon().' '.$item->title.'</a></li>';
}
/**
* {@inheritdoc }
*/
public function getActiveState($item)
{
return \Request::is($item->getRequest()) ? ' class="active"' : null;
}
/**
* {@inheritdoc }
*/
public function getDividerWrapper()
{
return '<li class="divider"></li>';
}
/**
* {@inheritdoc }
*/
public function getMenuWithDropDownWrapper($item)
{
return '<li class="has-dropdown">
<a href="#">
'.$item->getIcon().' '.$item->title.'
</a>
<ul class="dropdown">
'.$this->getChildMenuItems($item).'
</ul>
</li>' . PHP_EOL;
;
}
}
+15 -4
View File
@@ -3,7 +3,6 @@
namespace App\Models;
use Illuminate\Auth\Authenticatable;
use Illuminate\Auth\Passwords\CanResetPassword;
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Foundation\Auth\Access\Authorizable;
@@ -14,7 +13,6 @@ use Illuminate\Foundation\Auth\Access\Authorizable;
class User extends Model implements AuthenticableInterface
{
use Authenticatable, Authorizable;
public $timestamps = false;
protected $fillable = [
'email',
@@ -32,11 +30,24 @@ class User extends Model implements AuthenticableInterface
'password',
'remember_token',
];
const STATE_DELETED = 'deleted';
const STATE_BLOCKED = 'blocked';
const STATE_ACTIVE = 'active';
const ROLE_VISITOR = 'visitor';
const ROLE_EDITOR = 'editor';
const ROLE_ADMIN = 'admin';
}
/**
* Getter for Gravatar URL
*
* This method returns full path (url) to user's Gravatar. It accepts optional parameter for setting size.
*
* @param int $size size of rendered gravatar
*
* @return string
*/
public function gravatar($size = 50)
{
return "http://www.gravatar.com/avatar/" . md5(strtolower(trim($this->email))) . "?s=" . $size;
}
}
@@ -4,7 +4,7 @@ namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class AdminProvider extends ServiceProvider
class AdminMenusProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
@@ -28,14 +28,18 @@ class AdminProvider extends ServiceProvider
$menu->url(action('Admin\Dashboard@getIndex'), trans('admin/mainMenu.dashboard'), 1, ['icon' => 'fa fa-dashboard']);
$menu->dropdown(trans('admin/mainMenu.userManagement'), function($sub) {
$sub->url(action('Admin\UserManagement@getNewUser'), trans('admin/mainMenu.newUser'), 1, ['icon' => 'fa fa-user-plus']);
$sub->url(action('Admin\UserManagement@getOverview', ['state' => 'all']), trans('admin/mainMenu.usersOverview'), 2, ['icon' => 'fa fa-users']);
$sub->url(action('Admin\UserManagement@getOverview'), trans('admin/mainMenu.usersOverview'), 2, ['icon' => 'fa fa-users']);
}, ['icon' => 'fa fa-users']);
$menu->url('#', trans('admin/mainMenu.customFields'), 30, ['icon' => 'fa fa-code']);
$menu->url('#', trans('admin/mainMenu.settings'), 50, ['icon' => 'fa fa-gear']);
});
// create menu with user profile
\Menu::create('profileMenu', function ($menu) {
// @todo add profile menu
$menu->url('#', trans('admin/userManagement.profile'));
$menu->url('#', trans('admin/common.logout'));
});
}
-1
View File
@@ -13,7 +13,6 @@ class GlobalViewDataProvider extends ServiceProvider
*/
public function boot()
{
view()->share('something', 'some value');
view()->share('vendorName', 'ja s.r.o.');
}