Skip to content

Commit

Permalink
Merge pull request #287 from hydephp/rename-sidebar-views
Browse files Browse the repository at this point in the history
Rename sidebar views
  • Loading branch information
caendesilva authored Jul 29, 2022
2 parents f3d35ea + 8775e6a commit 940f24d
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ This update internally refactors how documentation sidebars are handled. If you
### Changed
- internal: Refactor how documentation sidebars are generated and handled
- internal: (Sidebar) categories are now internally referred to as "groups"
- internal: The sidebar related Blade views have been renamed

### Deprecated
- for soon-to-be removed features.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<ul id="sidebar-navigation-menu" role="list">
<ul id="sidebar" role="list">
@foreach ($sidebar->getGroups() as $group)
<li class="sidebar-category mb-4 mt-4 first:mt-0" role="listitem">
<h4 class="sidebar-category-heading text-base font-semibold mb-2 -ml-1">{{ Hyde::makeTitle($group ?? 'Other') }}</h4>
<ul class="sidebar-category-list ml-4" role="list">
@foreach ($sidebar->getItemsInGroup($group) as $item)
<x-hyde::docs.labeled-sidebar-navigation-menu-item :item="$item" :active="$item->route->getRouteKey() === $currentRoute->getRouteKey()" />
<x-hyde::docs.grouped-sidebar-item :item="$item" :active="$item->route->getRouteKey() === $currentRoute->getRouteKey()" />
@endforeach
</ul>
</li>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<ul id="sidebar-navigation-menu" role="list">
<ul id="sidebar" role="list">
@foreach ($sidebar->items as $item)
<li @class(['sidebar-navigation-item -ml-4 pl-4' , 'active bg-black/5 dark:bg-black/10'=> $item->route->getRouteKey() === $currentRoute->getRouteKey()])>
@if($item->route->getRouteKey() === $currentRoute->getRouteKey())
Expand Down
4 changes: 2 additions & 2 deletions packages/framework/resources/views/layouts/docs.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ class="p-4 overflow-y-auto border-y border-gray-300 dark:border-[#1b2533] h-[cal
@endphp

@if($sidebar->hasGroups())
@include('hyde::components.docs.labeled-sidebar-navigation-menu')
@include('hyde::components.docs.grouped-sidebar')
@else
@include('hyde::components.docs.sidebar-navigation-menu')
@include('hyde::components.docs.sidebar')
@endif
</nav>
<footer id="sidebar-footer" class="h-16 absolute p-4 w-full bottom-0 left-0 text-center leading-8">
Expand Down
14 changes: 7 additions & 7 deletions tests/Browser/HighLevelViewTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public function test_documentation_index()
$this->browse(function (Browser $browser) {
$browser->visit('/docs/index')
->assertSee('HydePHP Docs')
->assertNotPresent('#sidebar-navigation-menu > li')
->assertNotPresent('#sidebar > li')
->screenshot('docs/index')
->storeSourceAsHtml('docs/index');
});
Expand All @@ -142,8 +142,8 @@ public function test_documentation_site_with_pages()
->assertSee('Page1')
->assertSee('Page2')
->assertSee('Page3')
->assertPresent('#sidebar-navigation-menu > li.active')
->assertAriaAttribute('#sidebar-navigation-menu > li:nth-child(1) > a', 'current', 'true')
->assertPresent('#sidebar > li.active')
->assertAriaAttribute('#sidebar > li:nth-child(1) > a', 'current', 'true')
->screenshot('docs/with_sidebar_pages')
->storeSourceAsHtml('docs/with_sidebar_pages');
});
Expand All @@ -170,10 +170,10 @@ public function test_documentation_site_with_grouped_pages()
->assertSee('Page1')
->assertSee('Page2')
->assertSee('Page3')
->assertAttributeContains('#sidebar-navigation-menu > li', 'class', 'sidebar-category')
->assertSeeIn('#sidebar-navigation-menu > li:nth-child(1) > h4.sidebar-category-heading', 'Group 1')
->assertAriaAttribute('#sidebar-navigation-menu > li:nth-child(1) > ul > li.sidebar-navigation-item.active > a', 'current', 'true')
->assertSeeIn('#sidebar-navigation-menu > li:nth-child(2) > h4.sidebar-category-heading', 'Other')
->assertAttributeContains('#sidebar > li', 'class', 'sidebar-category')
->assertSeeIn('#sidebar > li:nth-child(1) > h4.sidebar-category-heading', 'Group 1')
->assertAriaAttribute('#sidebar > li:nth-child(1) > ul > li.sidebar-navigation-item.active > a', 'current', 'true')
->assertSeeIn('#sidebar > li:nth-child(2) > h4.sidebar-category-heading', 'Other')
->screenshot('docs/with_grouped_sidebar_pages')
->storeSourceAsHtml('docs/with_grouped_sidebar_pages');
});
Expand Down

0 comments on commit 940f24d

Please sign in to comment.