View Source PetalComponents.Helpers (petal_components v2.3.0)
For any helper functions used across multiple components. Ideally we keep this empty - components should be copy-pastable.
Summary
Functions
build_class(list, joiner \\ " ")
deprecated
Builds a class string from a given input list by joining them together
Generates a unique HTML ID based on the given string.
Functions
This function is deprecated. Phoenix handles lists of strings for classes now. No need for this..
Builds a class string from a given input list by joining them together
This code was taken from Elixirs Enum.join/2
function and optimized for
building class name (e.g removing empty strings and joining with " " by default)
Generates a unique HTML ID based on the given string.
Parameters
- string: The input string (e.g., heading or label)
- prefix: An optional prefix for the ID (default: "c")
Examples
iex> PetalComponents.Helpers.uniq_id("My Heading")
"c-my-heading-1234"
iex> PetalComponents.Helpers.uniq_id("My Label", "custom")
"custom-my-label-5678"