Class: LocoMotion::Configuration
- Inherits:
-
Object
- Object
- LocoMotion::Configuration
- Defined in:
- lib/loco_motion/configuration.rb
Overview
Configuration class for LocoMotion. Allows developers to customize default behavior across their application.
Instance Attribute Summary collapse
-
#default_alert_timeout ⇒ Integer
The default timeout (in milliseconds) for auto-dismissing alerts.
-
#default_icon_library ⇒ String, Symbol
The default icon library used by the
loco_iconhelper (and the universalicon:options) when nolibrary:is given. -
#default_icon_variant ⇒ String, ...
The default icon variant used when no
variant:is given. -
#icon_cache_path ⇒ String
Where
loco_motion:icons:cachestores the full icon libraries it downloads, and whereloco_motion:icons:synccopies from when treeshaking. -
#icon_content_paths ⇒ Array<String>
Glob patterns (relative to the application root) that
loco_motion:icons:syncscans for icon references when treeshaking the vendored icon set — the icon analogue of Tailwind'scontentpaths. -
#icon_dev_fallback ⇒ Boolean
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/iconsset. -
#icon_safelist ⇒ Array<String>
Icon references that
loco_motion:icons:syncmust always vendor, even when no static usage is found — the icon analogue of Tailwind'ssafelist.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
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_timeout ⇒ Integer
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).
52 53 54 |
# File 'lib/loco_motion/configuration.rb', line 52 def default_alert_timeout @default_alert_timeout end |
#default_icon_library ⇒ String, 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.
62 63 64 |
# File 'lib/loco_motion/configuration.rb', line 62 def default_icon_library @default_icon_library end |
#default_icon_variant ⇒ String, ...
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).
72 73 74 |
# File 'lib/loco_motion/configuration.rb', line 72 def default_icon_variant @default_icon_variant end |
#icon_cache_path ⇒ String
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.
110 111 112 |
# File 'lib/loco_motion/configuration.rb', line 110 def icon_cache_path @icon_cache_path end |
#icon_content_paths ⇒ Array<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.
82 83 84 |
# File 'lib/loco_motion/configuration.rb', line 82 def icon_content_paths @icon_content_paths end |
#icon_dev_fallback ⇒ Boolean
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.
126 127 128 |
# File 'lib/loco_motion/configuration.rb', line 126 def icon_dev_fallback @icon_dev_fallback end |
#icon_safelist ⇒ Array<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.
98 99 100 |
# File 'lib/loco_motion/configuration.rb', line 98 def icon_safelist @icon_safelist end |