FEATURE: style menu
This commit adds some markup to sidebars in admin.
This commit is contained in:
@@ -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;
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+14
-3
@@ -3,7 +3,6 @@
|
|||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use Illuminate\Auth\Authenticatable;
|
use Illuminate\Auth\Authenticatable;
|
||||||
use Illuminate\Auth\Passwords\CanResetPassword;
|
|
||||||
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Foundation\Auth\Access\Authorizable;
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||||
@@ -14,7 +13,6 @@ use Illuminate\Foundation\Auth\Access\Authorizable;
|
|||||||
class User extends Model implements AuthenticableInterface
|
class User extends Model implements AuthenticableInterface
|
||||||
{
|
{
|
||||||
use Authenticatable, Authorizable;
|
use Authenticatable, Authorizable;
|
||||||
|
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'email',
|
'email',
|
||||||
@@ -32,11 +30,24 @@ class User extends Model implements AuthenticableInterface
|
|||||||
'password',
|
'password',
|
||||||
'remember_token',
|
'remember_token',
|
||||||
];
|
];
|
||||||
|
|
||||||
const STATE_DELETED = 'deleted';
|
const STATE_DELETED = 'deleted';
|
||||||
const STATE_BLOCKED = 'blocked';
|
const STATE_BLOCKED = 'blocked';
|
||||||
const STATE_ACTIVE = 'active';
|
const STATE_ACTIVE = 'active';
|
||||||
const ROLE_VISITOR = 'visitor';
|
const ROLE_VISITOR = 'visitor';
|
||||||
const ROLE_EDITOR = 'editor';
|
const ROLE_EDITOR = 'editor';
|
||||||
const ROLE_ADMIN = 'admin';
|
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;
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
|
||||||
class AdminProvider extends ServiceProvider
|
class AdminMenusProvider extends ServiceProvider
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Bootstrap the application services.
|
* 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->url(action('Admin\Dashboard@getIndex'), trans('admin/mainMenu.dashboard'), 1, ['icon' => 'fa fa-dashboard']);
|
||||||
$menu->dropdown(trans('admin/mainMenu.userManagement'), function($sub) {
|
$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@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']);
|
}, ['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
|
// create menu with user profile
|
||||||
\Menu::create('profileMenu', function ($menu) {
|
\Menu::create('profileMenu', function ($menu) {
|
||||||
// @todo add profile menu
|
$menu->url('#', trans('admin/userManagement.profile'));
|
||||||
|
$menu->url('#', trans('admin/common.logout'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,7 +13,6 @@ class GlobalViewDataProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function boot()
|
public function boot()
|
||||||
{
|
{
|
||||||
view()->share('something', 'some value');
|
|
||||||
view()->share('vendorName', 'ja s.r.o.');
|
view()->share('vendorName', 'ja s.r.o.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -148,7 +148,7 @@ return [
|
|||||||
App\Providers\EventServiceProvider::class,
|
App\Providers\EventServiceProvider::class,
|
||||||
App\Providers\RouteServiceProvider::class,
|
App\Providers\RouteServiceProvider::class,
|
||||||
App\Providers\GlobalViewDataProvider::class,
|
App\Providers\GlobalViewDataProvider::class,
|
||||||
App\Providers\AdminProvider::class,
|
App\Providers\AdminMenusProvider::class,
|
||||||
|
|
||||||
],
|
],
|
||||||
/*
|
/*
|
||||||
|
|||||||
+3
-2
@@ -9,9 +9,10 @@ return [
|
|||||||
'nav-tab' => 'Pingpong\Menus\Presenters\Bootstrap\NavTabPresenter',
|
'nav-tab' => 'Pingpong\Menus\Presenters\Bootstrap\NavTabPresenter',
|
||||||
'sidebar' => 'Pingpong\Menus\Presenters\Bootstrap\SidebarMenuPresenter',
|
'sidebar' => 'Pingpong\Menus\Presenters\Bootstrap\SidebarMenuPresenter',
|
||||||
'navmenu' => 'Pingpong\Menus\Presenters\Bootstrap\NavMenuPresenter',
|
'navmenu' => 'Pingpong\Menus\Presenters\Bootstrap\NavMenuPresenter',
|
||||||
'foundation' => 'App\MenuPresenters\FoundationMenuPresenter',
|
'foundation-drilldown' => 'App\MenuPresenters\FoundationDrilldownMenuPresenter',
|
||||||
|
'foundation-dropdown' => 'App\MenuPresenters\FoundationDropdownMenuPresenter',
|
||||||
|
'foundation-dropdown-initialized' => 'App\MenuPresenters\FoundationInitializedDropdownMenuPresenter',
|
||||||
],
|
],
|
||||||
|
|
||||||
'ordering' => false,
|
'ordering' => false,
|
||||||
|
|
||||||
];
|
];
|
||||||
|
|||||||
Vendored
+12
-3
@@ -5,15 +5,24 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
header {
|
header {
|
||||||
background: #ddd;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
background: #eee;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
.login-form {
|
.login-form {
|
||||||
margin-top: 4em;
|
margin-top: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.active {
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Footer
|
||||||
|
*/
|
||||||
|
|
||||||
|
footer {
|
||||||
|
margin-top: 10em;
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
<?php
|
||||||
|
return [
|
||||||
|
'admin' => 'Administration',
|
||||||
|
'logout' => 'Log out'
|
||||||
|
];
|
||||||
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
return [
|
return [
|
||||||
'dashboard' => 'Dashboard',
|
'dashboard' => 'Dashboard',
|
||||||
'userManagement' => 'User Management',
|
'userManagement' => 'Users',
|
||||||
'newUser' => 'New User',
|
'newUser' => 'New User',
|
||||||
'usersOverview' => 'Overview'
|
'usersOverview' => 'Overview',
|
||||||
|
'customFields' => 'Custom fields',
|
||||||
|
'settings' => 'Settings'
|
||||||
];
|
];
|
||||||
@@ -10,6 +10,7 @@ return [
|
|||||||
'role_editor' => 'Editor',
|
'role_editor' => 'Editor',
|
||||||
'role_visitor' => 'Visitor',
|
'role_visitor' => 'Visitor',
|
||||||
'register' => 'Create user',
|
'register' => 'Create user',
|
||||||
'registrationSuccessfull' => 'New user successfully added.'
|
'registrationSuccessfull' => 'New user successfully added.',
|
||||||
|
'profile' => 'Your profile'
|
||||||
|
|
||||||
];
|
];
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
@yield('head_meta')
|
@yield('head_meta')
|
||||||
<title>@yield('pageName') {{$vendorName}}</title>
|
<title>@yield('pageName', @trans('admin/common.admin')) | {{$vendorName}}</title>
|
||||||
<link rel="stylesheet" href="{{asset('../resources/assets/css/foundation.min.css')}}" />
|
<link rel="stylesheet" href="{{asset('../resources/assets/css/foundation.min.css')}}" />
|
||||||
<link rel="stylesheet" href="{{asset('../resources/assets/css/font-awesome.min.css')}}" />
|
<link rel="stylesheet" href="{{asset('../resources/assets/css/font-awesome.min.css')}}" />
|
||||||
<link rel="stylesheet" href="{{asset('../resources/assets/css/admin.css')}}" />
|
<link rel="stylesheet" href="{{asset('../resources/assets/css/admin.css')}}" />
|
||||||
@@ -16,30 +16,38 @@
|
|||||||
<div id="container">
|
<div id="container">
|
||||||
|
|
||||||
<header class="row">
|
<header class="row">
|
||||||
<section class="logo columns large-2">
|
<section class="logo columns small-1 medium-3 large-2">
|
||||||
...
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="heading columns large-8">
|
<section class="heading columns small-10 medium-8 large-8">
|
||||||
<h1>{{$vendorName}}</h1>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="profile columns large-2">
|
<section class="profile columns small-10 medium-1 large-2">
|
||||||
{!! Menu::render('profileMenu') !!}
|
<ul class="vertical dropdown menu" data-dropdown-menu>
|
||||||
|
<li>
|
||||||
|
<a href="#">
|
||||||
|
<img src="{{Auth::user()->gravatar(25)}}" alt="" />
|
||||||
|
{{Auth::user()->getAttribute('name')}}
|
||||||
|
</a>
|
||||||
|
{!! Menu::render('profileMenu', 'foundation-dropdown-initialized') !!}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<section class="sidebar large-2 columns">
|
<section class="sidebar large-2 columns">
|
||||||
{!! Menu::render('mainMenu', 'foundation') !!}
|
{!! Menu::render('mainMenu', 'foundation-drilldown') !!}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section class="content large-10 columns">
|
<section class="content small-11 medium-9 large-10 columns">
|
||||||
@yield('content')
|
@yield('content')
|
||||||
</section>
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<footer>
|
<footer class="row text-center">
|
||||||
© {{$vendorName}} {{date('Y')}}
|
© {{$vendorName}} {{date('Y')}}
|
||||||
</footer>
|
</footer>
|
||||||
</div>
|
</div>
|
||||||
@@ -49,5 +57,9 @@
|
|||||||
|
|
||||||
@yield('javascripts')
|
@yield('javascripts')
|
||||||
|
|
||||||
|
<script type="application/javascript">
|
||||||
|
$ (document).foundation ();
|
||||||
|
</script>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user