Skip to content

Commit

Permalink
Refactor component to use attribute merging
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Mar 13, 2024
1 parent 6ba9eaf commit 3dba69a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<a href="{{ $item }}" {!! $item->isActive() ? 'aria-current="page"' : '' !!} @class([
<a href="{{ $item }}" {{ ($attributes->except('item')->class([
'navigation-link block my-2 md:my-0 md:inline-block py-1 text-gray-700 hover:text-gray-900 dark:text-gray-100',
'navigation-link-active border-l-4 border-indigo-500 md:border-none font-medium -ml-6 pl-5 md:ml-0 md:pl-0 bg-gray-100 dark:bg-gray-800 md:bg-transparent dark:md:bg-transparent' => $item->isActive()
])>{{ $item->getLabel() }}</a>
])->merge([
'aria-current' => ($item->isActive() ? 'page' : false),
])) }}>{{ $item->getLabel() }}</a>
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function testNavigationMenuWithRootPages()
$contents = $foo->compile();

$this->assertStringContainsString('<a href="foo.html" aria-current="page" class="', $contents);
$this->assertStringContainsString('<a href="bar.html" class="', $contents);
$this->assertStringContainsString('<a href="bar.html" class="', $contents);
}

public function testNavigationMenuWithDropdownPages()
Expand Down

0 comments on commit 3dba69a

Please sign in to comment.