LiveStyle.Manifest.ClassEntry (LiveStyle v0.12.0)

View Source

Entry structure for style classes.

There are two variants:

  • Static classes: have declarations
  • Dynamic classes: have all_props

Summary

Functions

Gets all_props from a dynamic class entry. Raises if called on a static entry.

Gets the atomic classes from an entry.

Gets the class string from an entry.

Gets the declarations from a static class entry. Raises if called on a dynamic entry.

Returns true if this is a dynamic class entry.

Creates a new dynamic class entry.

Creates a new static class entry.

Types

dynamic_entry()

@type dynamic_entry() :: [
  class_string: String.t(),
  atomic_classes: list(),
  all_props: [atom()]
]

static_entry()

@type static_entry() :: [
  class_string: String.t(),
  atomic_classes: list(),
  declarations: keyword()
]

t()

@type t() :: static_entry() | dynamic_entry()

Functions

all_props(entry)

@spec all_props(dynamic_entry()) :: [atom()]

Gets all_props from a dynamic class entry. Raises if called on a static entry.

atomic_classes(entry)

@spec atomic_classes(t()) :: list()

Gets the atomic classes from an entry.

class_string(entry)

@spec class_string(t()) :: String.t()

Gets the class string from an entry.

declarations(entry)

@spec declarations(static_entry()) :: keyword()

Gets the declarations from a static class entry. Raises if called on a dynamic entry.

dynamic?(entry)

@spec dynamic?(t()) :: boolean()

Returns true if this is a dynamic class entry.

new_dynamic(class_string, atomic_classes, all_props)

@spec new_dynamic(String.t(), list(), [atom()]) :: dynamic_entry()

Creates a new dynamic class entry.

Parameters

  • class_string - The space-separated class names
  • atomic_classes - List of atomic class definitions
  • all_props - All properties this dynamic class can set

Examples

ClassEntry.new_dynamic("x1abc", [...], [:opacity])

new_static(class_string, atomic_classes, declarations)

@spec new_static(String.t(), list(), keyword()) :: static_entry()

Creates a new static class entry.

Parameters

  • class_string - The space-separated class names
  • atomic_classes - List of atomic class definitions
  • declarations - The original style declarations

Examples

ClassEntry.new_static("x1abc x2def", [...], [display: "flex"])