Class: Satis::Card::Component

Inherits:
ApplicationComponent show all
Defined in:
app/components/satis/card/component.rb

Instance Attribute Summary collapse

Attributes inherited from ApplicationComponent

#original_view_context

Instance Method Summary collapse

Methods inherited from ApplicationComponent

add_helper, #component_name, #ct, #i18n_scope, #original_i18n_scope, #original_virtual_path

Constructor Details

#initialize(icon: nil, title: nil, description: nil, menu: nil, content_padding: true, header_background_color: { dark: 'bg-gray-800', light: 'bg-white' }, actions: [], key: nil) ⇒ Component

Returns a new instance of Component.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/components/satis/card/component.rb', line 12

def initialize(icon: nil,
               title: nil,
               description: nil,
               menu: nil,
               content_padding: true,
               header_background_color: {
                 dark: 'bg-gray-800', light: 'bg-white'
               },
               actions: [],
               key: nil)
  super
  @title = title
  @title = @title.reject(&:blank?).compact.join(' ') if @title.is_a?(Array)
  @description = description
  @icon = icon
  @menu = menu
  @content_padding = content_padding
  @header_background_color = header_background_color
  @initial_actions = actions
  @key = key
end

Instance Attribute Details

#content_paddingObject (readonly)

Returns the value of attribute content_padding.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def content_padding
  @content_padding
end

Returns the value of attribute custom_tabs_link_html.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def custom_tabs_link_html
  @custom_tabs_link_html
end

#descriptionObject (readonly)

Returns the value of attribute description.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def description
  @description
end

#header_background_colorObject (readonly)

Returns the value of attribute header_background_color.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def header_background_color
  @header_background_color
end

#iconObject (readonly)

Returns the value of attribute icon.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def icon
  @icon
end

#initial_actionsObject (readonly)

Returns the value of attribute initial_actions.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def initial_actions
  @initial_actions
end

#keyObject (readonly)

Returns the value of attribute key.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def key
  @key
end

Returns the value of attribute menu.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def menu
  @menu
end

#titleObject (readonly)

Returns the value of attribute title.



10
11
12
# File 'app/components/satis/card/component.rb', line 10

def title
  @title
end

Instance Method Details



34
35
36
37
# File 'app/components/satis/card/component.rb', line 34

def custom_tabs_link(&block)
  return unless block_given?
  @custom_tabs_link_html = block.call.html_safe
end

#header?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'app/components/satis/card/component.rb', line 43

def header?
  icon.present? || title.present? || description.present? || menu
end

#tabs?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'app/components/satis/card/component.rb', line 39

def tabs?
  tabs.present?
end