Module: Weft::Shorthands
- Defined in:
- lib/weft/shorthands.rb
Overview
Registry for named interaction shorthands. Each shorthand is a preset of trigger/swap/target defaults that Context expands via loads:.
Shipped presets are registered at the bottom of this file. Users will be able to register custom shorthands in v1.x via the same API.
Class Method Summary collapse
-
.lookup(name) ⇒ Object
Look up a registered shorthand by name.
-
.register(name, **defaults) ⇒ Object
Register a named interaction shorthand.
-
.registered ⇒ Object
All registered shorthand names.
Class Method Details
.lookup(name) ⇒ Object
Look up a registered shorthand by name. Returns the defaults hash or nil.
19 20 21 |
# File 'lib/weft/shorthands.rb', line 19 def lookup(name) registry[name] end |
.register(name, **defaults) ⇒ Object
Register a named interaction shorthand.
Weft::Shorthands.register :tooltip, trigger: :hover, swap: :fill
14 15 16 |
# File 'lib/weft/shorthands.rb', line 14 def register(name, **defaults) registry[name] = defaults end |
.registered ⇒ Object
All registered shorthand names.
24 25 26 |
# File 'lib/weft/shorthands.rb', line 24 def registered registry.keys end |