-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from tattersoftware/styles
Styles & Fixes
- Loading branch information
Showing
10 changed files
with
124 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php namespace Tatter\Menus\Styles; | ||
|
||
use Spatie\Menu\Link; | ||
|
||
/** | ||
* AdminLTE Styler Trait | ||
* | ||
* Applies CSS classes & styles | ||
* to start a Menu for AdminLTE. | ||
* | ||
* @mixin \Tatter\Menus\Menu | ||
*/ | ||
trait AdminLTEStyle | ||
{ | ||
protected function applyAdminLTEStyle(): void | ||
{ | ||
$this->builder | ||
->addClass('nav nav-pills nav-sidebar flex-column') | ||
->setActiveClass('active menu-open') | ||
->setAttribute('data-widget', 'treeview') | ||
->setAttribute('role', 'menu') | ||
->setAttribute('data-accordion', 'false') | ||
->registerFilter(function (Link $link) { | ||
$link->addParentClass('nav-item'); | ||
$link->addClass('nav-link'); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Traits/BreadcrumbsStyle.php → src/Styles/BreadcrumbsStyle.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<?php namespace Tatter\Menus\Traits; | ||
<?php namespace Tatter\Menus\Styles; | ||
|
||
use Spatie\Menu\Link; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php namespace Tests\Support; | ||
|
||
use Tatter\Menus\Menu; | ||
use Tatter\Menus\Styles\BootstrapStyle; | ||
use Tatter\Menus\Styles\AdminLTEStyle; | ||
use Tests\Support\MenusTestCase; | ||
|
||
class StylesTest extends MenusTestCase | ||
{ | ||
public function testBootstrapStyleAppliesClasses() | ||
{ | ||
$menu = new class extends Menu { | ||
|
||
use BootstrapStyle; | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->builder | ||
->link(site_url('/'), 'Home') | ||
->link(site_url('/current'), 'Grain') | ||
->render(); | ||
} | ||
}; | ||
|
||
$result = $menu->__toString(); | ||
|
||
$this->assertStringContainsString('li class="nav-item"', $result); | ||
$this->assertStringContainsString('class="nav-link"', $result); | ||
} | ||
|
||
public function testAdminLTEStyleAppliesClasses() | ||
{ | ||
$menu = new class extends Menu { | ||
|
||
use AdminLTEStyle; | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->builder | ||
->link(site_url('/'), 'Home') | ||
->link(site_url('/current'), 'Grain') | ||
->render(); | ||
} | ||
}; | ||
|
||
$result = $menu->__toString(); | ||
|
||
$this->assertStringContainsString('data-widget="treeview"', $result); | ||
$this->assertStringContainsString('class="nav nav-pills', $result); | ||
$this->assertStringContainsString('class="nav-link"', $result); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.