Skip to content

feat: section#27

Merged
shavonn merged 1 commit into
mainfrom
feat/section
May 4, 2026
Merged

feat: section#27
shavonn merged 1 commit into
mainfrom
feat/section

Conversation

@shavonn
Copy link
Copy Markdown
Contributor

@shavonn shavonn commented May 4, 2026

No description provided.

Copilot AI review requested due to automatic review settings May 4, 2026 03:38
@shavonn shavonn merged commit 97a4009 into main May 4, 2026
22 checks passed
@shavonn shavonn deleted the feat/section branch May 4, 2026 03:39
@github-actions github-actions Bot mentioned this pull request May 4, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a new section concept to the navigation library so consumers can organize navigation items into top-level structural containers alongside the existing collapsible groups.

Changes:

  • Adds Item::section(), nav_section(), and NavigationBuilder::section() to create section nodes in config, helpers, and runtime registration.
  • Adds validation and exception messaging intended to prevent sections from being nested under sections or groups.
  • Documents the new feature in the README and adds unit tests covering section creation, rendering, helper usage, and some invalid nesting cases.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/Unit/SectionsTest.php Adds section-focused unit tests for builders, helpers, rendering, and invalid nesting.
src/helpers.php Introduces the nav_section() helper and updates group helper docs.
src/NavigationBuilder.php Adds runtime builder support for registering sections.
src/ItemBuilder.php Adds the new Item::section() factory and section metadata defaults.
src/Exceptions/InvalidNavigationItemException.php Adds a dedicated exception factory for invalid nested sections.
src/Data/NavigationItem.php Extends validation to reject some nested section configurations.
README.md Documents sections, helper usage, builder usage, nesting rules, and output shape.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +194 to +205
// Sections cannot be nested inside sections or groups
$isSection = ! empty($data['section']);
$isGroup = ! empty($data['group']);

if (($isSection || $isGroup) && isset($data['children']) && is_array($data['children'])) {
foreach ($data['children'] as $child) {
if ($child instanceof ItemBuilder) {
$child = $child->toArray();
}

if (is_array($child) && ! empty($child['section'])) {
throw InvalidNavigationItemException::nestedSection($data, $isSection ? 'section' : 'group');
Comment thread src/ItemBuilder.php
Comment on lines +148 to +156
public static function section(string $label, array $children = []): static
{
$item = new static($label);
$item->meta['section'] = true;
$item->meta['collapsible'] = false;
$item->meta['collapsed'] = false;
$item->children = $children;

return $item;
InvalidNavigationItemException::class,
'Navigation sections cannot be nested inside a group.'
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants