Class: LocoMotion::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/loco_motion/configuration.rb

Overview

Configuration class for LocoMotion. Allows developers to customize default behavior across their application.

Examples:

Configure LocoMotion with custom settings

LocoMotion.configure do |config|
  config.default_alert_timeout = 10000
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



128
129
130
131
132
133
134
135
136
# File 'lib/loco_motion/configuration.rb', line 128

def initialize
  @default_alert_timeout = 5000 # 5 seconds default
  @default_icon_library = :heroicons
  @default_icon_variant = :outline
  @icon_content_paths = ["app/**/*.{rb,erb,haml,slim}"]
  @icon_safelist = []
  @icon_cache_path = "tmp/loco_motion/icons"
  @icon_dev_fallback = true
end

Instance Attribute Details

#default_alert_timeoutInteger

The default timeout (in milliseconds) for auto-dismissing alerts. This value is used when an Alert component has a timeout set but no explicit value is provided. The default is 5000ms (5 seconds).

Returns:

  • (Integer)

    The default timeout in milliseconds



52
53
54
# File 'lib/loco_motion/configuration.rb', line 52

def default_alert_timeout
  @default_alert_timeout
end

#default_icon_libraryString, Symbol

The default icon library used by the loco_icon helper (and the universal icon: options) when no library: is given. Defaults to :heroicons. Set this to make another synced library your default, e.g. config.default_icon_library = :lucide.

Returns:

  • (String, Symbol)

    The default icon library



62
63
64
# File 'lib/loco_motion/configuration.rb', line 62

def default_icon_library
  @default_icon_library
end

#default_icon_variantString, ...

The default icon variant used when no variant: is given. Defaults to :outline (Heroicons' outline style). When changing #default_icon_library to a library with different variants, set this to match (or nil for a flat library that has no variant subdirectories).

Returns:

  • (String, Symbol, nil)

    The default icon variant



72
73
74
# File 'lib/loco_motion/configuration.rb', line 72

def default_icon_variant
  @default_icon_variant
end

#icon_cache_pathString

Where loco_motion:icons:cache stores the full icon libraries it downloads, and where loco_motion:icons:sync copies from when treeshaking. Resolved relative to the application root; the default lives under tmp/ (which Rails already gitignores) so the full set stays on your machine while only the used icons are vendored into app/assets/svg/icons and committed.

Returns:

  • (String)

    The local icon cache path



110
111
112
# File 'lib/loco_motion/configuration.rb', line 110

def icon_cache_path
  @icon_cache_path
end

#icon_content_pathsArray<String>

Glob patterns (relative to the application root) that loco_motion:icons:sync scans for icon references when treeshaking the vendored icon set — the icon analogue of Tailwind's content paths. Only icons referenced in these files (plus #icon_safelist) are vendored.

Returns:

  • (Array<String>)

    The content glob patterns to scan



82
83
84
# File 'lib/loco_motion/configuration.rb', line 82

def icon_content_paths
  @icon_content_paths
end

#icon_dev_fallbackBoolean

Whether the icon renderer may fall back to the full local cache (#icon_cache_path) in development when an icon is missing from the vendored app/assets/svg/icons set. Defaults to true, which keeps the development loop fast: a freshly-referenced icon renders on the next refresh without re-running loco_motion:icons:sync.

Set this to false to resolve icons strictly from the vendored set in every environment — a used-but-unvendored icon then fails loudly in development and local test runs instead of surfacing for the first time in production or CI.

Returns:

  • (Boolean)

    Whether the development cache fallback is enabled



126
127
128
# File 'lib/loco_motion/configuration.rb', line 126

def icon_dev_fallback
  @icon_dev_fallback
end

#icon_safelistArray<String>

Icon references that loco_motion:icons:sync must always vendor, even when no static usage is found — the icon analogue of Tailwind's safelist. Use it for dynamically-named icons the scanner cannot see (e.g. loco_icon("bars-#{n}") or a name pulled from a database).

Each entry is a qualified [library:]name[/variant] token (see Icons::Reference), e.g. "information-circle", "lucide:heart", "bolt/solid", or "phosphor:gear/bold". An omitted library / variant falls back to #default_icon_library / #default_icon_variant.

Returns:

  • (Array<String>)

    The safelisted icon references



98
99
100
# File 'lib/loco_motion/configuration.rb', line 98

def icon_safelist
  @icon_safelist
end