Skip to content

Commit

Permalink
Update navigation item facade to support the attribute parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
caendesilva committed Jul 10, 2024
1 parent c087bbf commit 33e40d8
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/framework/src/Facades/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class Navigation
* @param string<\Hyde\Support\Models\RouteKey>|string $destination Route key, or an external URI.
* @param string|null $label If not provided, Hyde will try to get it from the route's connected page, or from the URL.
* @param int|null $priority If not provided, Hyde will try to get it from the route or the default priority of 500.
* @param array<string, scalar> $attributes Additional attributes for the navigation item.
*/
public static function item(string $destination, ?string $label = null, ?int $priority = null): array
public static function item(string $destination, ?string $label = null, ?int $priority = null, array $attributes = []): array
{
return compact('destination', 'label', 'priority');
return compact('destination', 'label', 'priority', 'attributes');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -497,14 +497,17 @@ public function testCanSetCustomNavigationItemsInTheYamlConfig()
'destination' => 'https://example.com',
'label' => 'Example',
'priority' => 100,
'attributes' => [],
], [
'destination' => 'about',
'label' => 'About Us',
'priority' => 200,
'attributes' => [],
], [
'destination' => 'contact',
'label' => 'Contact',
'priority' => 300,
'attributes' => [],
],
], $configItems);

Expand Down Expand Up @@ -549,6 +552,7 @@ public function testOnlyNeedToAddDestinationToYamlConfiguredNavigationItems()
'destination' => 'about.html',
'label' => null,
'priority' => null,
'attributes' => [],
],
], $configItems);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public function testItem()
'destination' => 'home',
'label' => 'Home',
'priority' => 100,
'attributes' => [],
], $item);
}

Expand All @@ -31,6 +32,7 @@ public function testItemWithOnlyDestination()
'destination' => 'home',
'label' => null,
'priority' => null,
'attributes' => [],
], $item);
}

Expand All @@ -42,6 +44,7 @@ public function testItemWithUrl()
'destination' => 'https://example.com',
'label' => 'External',
'priority' => 200,
'attributes' => [],
], $item);
}
}

0 comments on commit 33e40d8

Please sign in to comment.