Clarity.Perspective.Lens (Clarity v0.5.1)

Copy Markdown View Source

Data structure representing a lens that provides a specific view onto the graph.

A lens filters the graph to a subset relevant for a certain audience and defines how that filtered view should be presented, including the starting vertex and default content ordering.

Summary

Functions

Default vertex type filter that shows all vertex types.

Default content sorter that sorts by priority, then alphabetically by name, then by id for deterministic ordering.

Types

content_sorter_fn()

@type content_sorter_fn() :: (Clarity.Content.t(), Clarity.Content.t() -> boolean())

icon_fn()

@type icon_fn() :: (-> Phoenix.LiveView.Rendered.t())

show_vertex_types_fn()

@type show_vertex_types_fn() :: ([module()] -> [module()])

t()

@type t() :: %Clarity.Perspective.Lens{
  content_sorter: content_sorter_fn(),
  description: String.t() | nil,
  filter: Clarity.Graph.Filter.filter(),
  icon: icon_fn(),
  id: String.t(),
  name: String.t(),
  show_vertex_types: show_vertex_types_fn()
}

Functions

default_show_vertex_types(types)

@spec default_show_vertex_types([module()]) :: [module()]

Default vertex type filter that shows all vertex types.

This is the default function used by lenses unless they specify their own show_vertex_types function. Returns all types unchanged.

sort_alphabetically(a, b)

@spec sort_alphabetically(Clarity.Content.t(), Clarity.Content.t()) :: boolean()

Default content sorter that sorts by priority, then alphabetically by name, then by id for deterministic ordering.

This is the default sorting function used by lenses unless they specify their own content_sorter function. Content providers can implement the sort_priority/0 callback to control their position (lower values first).