-
Notifications
You must be signed in to change notification settings - Fork 2
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 #14 from cameronmurphy/feature/12-active-state
Active state
- Loading branch information
Showing
15 changed files
with
142 additions
and
61 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
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 |
---|---|---|
@@ -1,9 +1,10 @@ | ||
{% apply spaceless %} | ||
{% if menu_item.label is defined and (menu_item.route is defined or menu_item.url is defined) %} | ||
<li class="nav-item"> | ||
<a class="nav-link" {% include '@BootstrapMenu/href.html.twig' with { menu_item } %}> | ||
{{- menu_item.label -}} | ||
</a> | ||
</li> | ||
{% set is_active = app.request.attributes.get('_route') == menu_item.route %} | ||
<li class="nav-item"> | ||
<a class="nav-link{% if is_active %} active{% endif %}"{% if is_active %} aria-current="page"{% endif %} {% include '@BootstrapMenu/href.html.twig' with { menu_item } %}> | ||
{{- menu_item.label -}} | ||
</a> | ||
</li> | ||
{% endif %} | ||
{% endapply %} |
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
8 changes: 1 addition & 7 deletions
8
Tests/Twig/Extension/__snapshots__/MenuExtensionTest__testRenderMenuBootstrap4__1.txt
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,7 +1 @@ | ||
|
||
|
||
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 1</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-2-route?test=123">Dropdown Item 2 (should render a dropdown-item)</a></div></li> | ||
|
||
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 2</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-item-3-route">Dropdown Item 3 (should render a dropdown-item because user has permission)</a><a class="dropdown-item" href="https://disney.com">Dropdown Item 4 (should render a dropdown-item linking to Disney)</a></div></li><li class="nav-item"><a class="nav-link" href="/app-link-1-route">Link 1 (this should render a nav-link)</a></li> | ||
|
||
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 4</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-item-8-route">Dropdown Item 8</a><div class="dropdown-divider"></div><h6 class="dropdown-header">Divider 2 (should render a dropdown-header)</h6><a class="dropdown-item" href="/app-dropdown-item-9-route">Dropdown Item 9</a><div class="dropdown-divider"></div><a class="dropdown-item" href="/app-dropdown-item-10-route">Dropdown Item 10</a><a class="dropdown-item" href="/app-dropdown-item-11-route">Dropdown Item 11</a><div class="dropdown-divider"></div><h6 class="dropdown-header">Divider 5</h6><a class="dropdown-item" href="/app-dropdown-item-13-route">Dropdown Item 13</a></div></li> | ||
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 1</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-2-route?test=123">Dropdown Item 2 (should render a dropdown-item)</a></div></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 2</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-item-3-route">Dropdown Item 3 (should render a dropdown-item because user has permission)</a><a class="dropdown-item" href="https://disney.com">Dropdown Item 4 (should render a dropdown-item linking to Disney)</a></div></li><li class="nav-item"><a class="nav-link active" aria-current="page" href="/app-link-1-route">Link 1 (this should render an active nav-link)</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 4</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-item-8-route">Dropdown Item 8</a><div class="dropdown-divider"></div><h6 class="dropdown-header">Divider 2 (should render a dropdown-header)</h6><a class="dropdown-item" href="/app-dropdown-item-9-route">Dropdown Item 9</a><div class="dropdown-divider"></div><a class="dropdown-item" href="/app-dropdown-item-10-route">Dropdown Item 10</a><a class="dropdown-item" href="/app-dropdown-item-11-route">Dropdown Item 11</a><div class="dropdown-divider"></div><h6 class="dropdown-header">Divider 5</h6><a class="dropdown-item" href="/app-dropdown-item-13-route">Dropdown Item 13</a></div></li> |
1 change: 1 addition & 0 deletions
1
.../__snapshots__/MenuExtensionTest__testRenderMenuBootstrap5WithActiveDropdownStyles__1.txt
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 @@ | ||
<li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 1</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-2-route?test=123">Dropdown Item 2 (should render a dropdown-item)</a></div></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 2</a><div class="dropdown-menu"><a class="dropdown-item" href="/app-dropdown-item-3-route">Dropdown Item 3 (should render a dropdown-item because user has permission)</a><a class="dropdown-item" href="https://disney.com">Dropdown Item 4 (should render a dropdown-item linking to Disney)</a></div></li><li class="nav-item"><a class="nav-link" href="/app-link-1-route">Link 1 (this should render an active nav-link)</a></li><li class="nav-item dropdown"><a class="nav-link dropdown-toggle active" aria-current="page" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown Menu 4</a><div class="dropdown-menu"><a class="dropdown-item active" aria-current="page" href="/app-dropdown-item-8-route">Dropdown Item 8</a><div class="dropdown-divider"></div><h6 class="dropdown-header">Divider 2 (should render a dropdown-header)</h6><a class="dropdown-item" href="/app-dropdown-item-9-route">Dropdown Item 9</a><div class="dropdown-divider"></div><a class="dropdown-item" href="/app-dropdown-item-10-route">Dropdown Item 10</a><a class="dropdown-item" href="/app-dropdown-item-11-route">Dropdown Item 11</a><div class="dropdown-divider"></div><h6 class="dropdown-header">Divider 5</h6><a class="dropdown-item" href="/app-dropdown-item-13-route">Dropdown Item 13</a></div></li> |
Oops, something went wrong.