View Source LiveViewUI.UI.Helper (LiveViewUI v0.0.7)

Provides utility functions for handling UI elements within LiveView components.

Summary

Functions

Converts a list of CSS class names into a single string with unique classes only.

Generates a unique identifier for a LiveView component.

Functions

Converts a list of CSS class names into a single string with unique classes only.

Parameters

  • classes: A list of strings representing CSS class names, potentially with duplicates.

Examples

iex> LiveViewUI.UI.cn(["button", "active", "button"])
"active button"

Returns

  • A string containing unique class names, sorted and joined by spaces.

Generates a unique identifier for a LiveView component.

Examples

# Example of a typical unique identifier output
iex> id = LiveViewUI.UI.unique_id()
iex> String.starts_with?(id, "LV")
true
iex> byte_size(id)
6

Returns

  • A string starting with "LV" followed by a unique alphanumeric sequence.