Class: FComponents::Button::Component

Inherits:
FComponents::Base show all
Defined in:
app/components/f_components/button/component.rb

Constant Summary collapse

TYPE_CLASSES =
{
  primary: 'bt--primary',
  secondary: 'bt--primary bt--outlined',
  tertiary: 'bt--tertiary',
  custom: ''
}.freeze
MODIFIERS =
{
  success: 'bt--success',
  secondary: 'bt--secondary',
  error: 'bt--error',
  white: 'bt--white',
  warning: 'bt--warning',
  fit: 'w--fit max-w--fit',
  full: 'bt--full',
  outlined: 'bt--outlined',
  small: 'bt--smr',
  large: 'bt--lg',
  centered: 'mx--auto'
}.freeze
MODS =
MODIFIERS.to_h.deep_dup

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from FComponents::Base

call

Methods included from ComponentsHelper

#component, #fcomponent

Constructor Details

#initialize(title, href = nil, **options) ⇒ Component

Returns a new instance of Component.



32
33
34
35
36
37
38
39
40
41
# File 'app/components/f_components/button/component.rb', line 32

def initialize(title, href = nil, **options)
  @title     = title
  @href      = href || 'javascript: void(0);'
  @modifiers = options.delete(:mods)
  @type      = options.delete(:type) || :primary
  @tag       = options.delete(:tag) || :a
  @class     = options.delete(:class) || ''
  @left_icon = options.delete(:left_icon)
  @options   = options
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



30
31
32
# File 'app/components/f_components/button/component.rb', line 30

def href
  @href
end

#optionsObject (readonly)

Returns the value of attribute options.



30
31
32
# File 'app/components/f_components/button/component.rb', line 30

def options
  @options
end