Raxol.Protocols.ComponentFramework (Raxol v2.0.1)

View Source

Protocol-based component framework for Raxol.

This module provides a modern, protocol-driven approach to building UI components that can be rendered, styled, and handle events in a unified way.

Key Features

  • Protocol-based composition for maximum flexibility
  • Automatic protocol implementation injection
  • Theme and style management integration
  • Event handling with bubbling and propagation
  • Performance optimizations through protocol dispatch

Usage

defmodule MyComponent do
  use Raxol.Protocols.ComponentFramework

  defcomponent :my_widget do
    @props [:title, :content, :style]
    @events [:click, :change]
    @themeable true

    def render(component, opts) do
      # Component rendering logic
    end
  end
end

Summary

Functions

Macro executed before compilation to inject protocol implementations.

Macro for defining protocol-aware components.

Add a child component to a parent component.

Add multiple children to a component.

Apply a theme to a component and all its children.

Create a component with the given type and properties.

Set an event handler for a component.

Update component props.

Update component state.

Functions

__before_compile__(env)

(macro)

Macro executed before compilation to inject protocol implementations.

__using__(opts \\ [])

(macro)

Macro for defining protocol-aware components.

add_child(parent, child)

Add a child component to a parent component.

add_children(parent, children)

Add multiple children to a component.

apply_theme(component, theme)

Apply a theme to a component and all its children.

component(module, type, props \\ %{}, opts \\ [])

Create a component with the given type and properties.

on_event(component, event_type, handler)

Set an event handler for a component.

set_props(component, new_props)

Update component props.

set_state(component, new_state)

Update component state.