Search documentation of phoenix_kit

# PhoenixKit.Dashboard.TabHelpers (phoenix_kit v1.7.87)

Copy Markdown View Source

Shared helper functions for dashboard sidebar navigation.

Extracted from `AdminSidebar` and `Sidebar` to eliminate duplication. Import this module in sidebar components to use these functions in HEEX templates.

## Summary

### Functions

add_active_state(tabs, current_path)

Sets the `:active` key on each tab based on path matching.

filter_top_level(tabs)

Filters to only top-level tabs (no parent).

get_subtabs_for(parent_id, all_tabs)

Gets subtabs for a given parent tab ID, sorted by priority.

group_tabs(tabs)

Groups tabs by their `:group` field.

sorted_groups(groups, grouped_tabs)

Filters to groups that have tabs and sorts by priority.

## Functions

# add_active_state(tabs, current_path)

    @spec add_active_state([PhoenixKit.Dashboard.Tab.t()], String.t()) :: [map()]

Sets the `:active` key on each tab based on path matching.

# filter_top_level(tabs)

    @spec filter_top_level([PhoenixKit.Dashboard.Tab.t()]) :: [
      PhoenixKit.Dashboard.Tab.t()
    ]

Filters to only top-level tabs (no parent).

# get_subtabs_for(parent_id, all_tabs)

    @spec get_subtabs_for(atom(), [PhoenixKit.Dashboard.Tab.t()]) :: [
      PhoenixKit.Dashboard.Tab.t()
    ]

Gets subtabs for a given parent tab ID, sorted by priority.

# group_tabs(tabs)

    @spec group_tabs([PhoenixKit.Dashboard.Tab.t()]) :: %{
      optional(atom()) => [PhoenixKit.Dashboard.Tab.t()]
    }

Groups tabs by their `:group` field.

# sorted_groups(groups, grouped_tabs)

    @spec sorted_groups([map()], map()) :: [map()]

Filters to groups that have tabs and sorts by priority.