Skip to content
docsv0.34.0

SidebarComponent

The panel's sidebar as a Milpa Component: the brand, and every discovered section listed under its group (greenhouse decisions/0210, wireframe 1a of decisions/0203: `ADMIN / APP / AGENT`). The panel composes its own sidebar instead of `milpa/live`'s `dashboard-sidebar` because that primitive has no group: its template lists every item under one literal heading, and its mount normalizes each item to `{key, label, href}` — the glyph a section declares never reaches the renderer. This component takes the same flat `items` (each with an optional `group`, and the `icon`) and groups them at mount: one group per distinct value, in the house order — {@see AdminSection::GROUP_ADMIN}, {@see AdminSection::GROUP_APP}, {@see AdminSection::GROUP_AGENT}, then any other name alphabetically (case-insensitively and in its own alphabet: `año` sorts among the a's, `Zeta` after `beta`, never by byte). Within a group the items keep the order they arrived in, which is the catalogue's (`order`, then `id`); an item with no group is the app's. It has no actions: navigating is the anchor's job, and the active item is a prop the shell sets.

SidebarComponent::contract()

public static function contract(): Milpa\Live\ValueObjects\ComponentContract

The contract: brand, the panel's home, the active key and the flat items to group.

SidebarComponent::mount()

public function mount(array $props, Milpa\Live\ValueObjects\ComponentContext $context): Milpa\Live\ValueObjects\StateSnapshot

Mount: the active key is the state; the brand, the home link and the grouped items ride in meta.

Parameters

Parameters of mount()
NameTypeDescription
$propsarray
$contextMilpa\Live\ValueObjects\ComponentContext

SidebarComponent::handle()

public function handle(Milpa\Live\ValueObjects\InteractionRequest $request): Milpa\Live\ValueObjects\InteractionResult

No action is declared: the anchors navigate, the shell names the active item.

Parameters

Parameters of handle()
NameTypeDescription
$requestMilpa\Live\ValueObjects\InteractionRequest

SidebarComponent::groups()

public static function groups(?mixed $items): array

The flat items grouped: one entry per distinct `group` value (an item without one is the app's), in the house order — admin, app, agent, then the rest alphabetically, case-insensitively and in their own alphabet (two names equal but for case keep byte order between them) — each carrying its items in the order they arrived. A group's key is always a string, a numeric name included (PHP would have made it an int key). A JSON-encoded list is accepted like an array (a markup attribute); anything that is not a list of arrays is no item.

Parameters

Parameters of groups()
NameTypeDescription
$items?mixed