Class: BootstrapConcerns::Option
- Inherits:
-
Object
- Object
- BootstrapConcerns::Option
- Defined in:
- lib/bootstrap_concerns/option.rb
Constant Summary collapse
- BUTTON_BASE_CLASS =
"btn".freeze
- DEFAULT_BUTTON_COLOR =
"primary".freeze
Class Method Summary collapse
- .options_with_base_class(options, *base_class) ⇒ Object
- .options_with_button_class(options = {}) ⇒ Object
- .prefixed_option(options, key:, prefix:, default: nil) ⇒ Object
Class Method Details
.options_with_base_class(options, *base_class) ⇒ Object
17 18 19 20 21 |
# File 'lib/bootstrap_concerns/option.rb', line 17 def (, *base_class) .merge( class: (base_class + [[:class]]).compact.join(" ") ) end |
.options_with_button_class(options = {}) ⇒ Object
7 8 9 10 11 |
# File 'lib/bootstrap_concerns/option.rb', line 7 def ( = {}) color = prefixed_option(, key: :color, prefix: BUTTON_BASE_CLASS, default: DEFAULT_BUTTON_COLOR) size = prefixed_option(, key: :size, prefix: BUTTON_BASE_CLASS) (, BUTTON_BASE_CLASS, color, size) end |
.prefixed_option(options, key:, prefix:, default: nil) ⇒ Object
13 14 15 |
# File 'lib/bootstrap_concerns/option.rb', line 13 def prefixed_option(, key:, prefix:, default: nil) (.delete(key) || default)&.then { "#{prefix}-#{it}" } end |