Class: Satis::Card::Component
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Satis::Card::Component
- Defined in:
- app/components/satis/card/component.rb
Instance Attribute Summary collapse
-
#content_padding ⇒ Object
readonly
Returns the value of attribute content_padding.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#header_background_color ⇒ Object
readonly
Returns the value of attribute header_background_color.
-
#icon ⇒ Object
readonly
Returns the value of attribute icon.
-
#identifier ⇒ Object
readonly
Returns the value of attribute identifier.
-
#initial_actions ⇒ Object
readonly
Returns the value of attribute initial_actions.
-
#key ⇒ Object
readonly
Returns the value of attribute key.
-
#menu ⇒ Object
readonly
Returns the value of attribute menu.
-
#persist ⇒ Object
readonly
Returns the value of attribute persist.
-
#scope ⇒ Object
writeonly
Sets the attribute scope.
Attributes inherited from ApplicationComponent
Instance Method Summary collapse
- #custom_tabs_link(&block) ⇒ Object
- #header? ⇒ Boolean
-
#initialize(identifier = nil, icon: nil, title: nil, description: nil, menu: nil, content_padding: true, header_background_color: { dark: 'bg-gray-800', light: 'bg-white' }, custom_tabs_link: nil, scope: [], actions: [], key: nil, persist: true) ⇒ Component
constructor
A new instance of Component.
-
#title ⇒ Object
def key return unless @persist.
Methods inherited from ApplicationComponent
Constructor Details
#initialize(identifier = nil, icon: nil, title: nil, description: nil, menu: nil, content_padding: true, header_background_color: { dark: 'bg-gray-800', light: 'bg-white' }, custom_tabs_link: nil, scope: [], actions: [], key: nil, persist: true) ⇒ Component
Returns a new instance of Component.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'app/components/satis/card/component.rb', line 13 def initialize(identifier = nil, icon: nil, title: nil, description: nil, menu: nil, content_padding: true, header_background_color: { dark: 'bg-gray-800', light: 'bg-white' }, custom_tabs_link: nil, scope: [], actions: [], key: nil, persist: true) super if identifier.blank? ActiveSupport::Deprecation.warn('Calling sts.card with the id parameter will become mandatory') end @identifier = identifier @title = title @title = @title.reject(&:blank?).compact.join(' ') if @title.is_a?(Array) @description = description @icon = icon @menu = @content_padding = content_padding @header_background_color = header_background_color @initial_actions = actions @persist = persist @key = key @custom_tabs_link = custom_tabs_link @scope = scope.present? ? scope : identifier end |
Instance Attribute Details
#content_padding ⇒ Object (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 |
#description ⇒ Object (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_color ⇒ Object (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 |
#icon ⇒ Object (readonly)
Returns the value of attribute icon.
10 11 12 |
# File 'app/components/satis/card/component.rb', line 10 def icon @icon end |
#identifier ⇒ Object (readonly)
Returns the value of attribute identifier.
10 11 12 |
# File 'app/components/satis/card/component.rb', line 10 def identifier @identifier end |
#initial_actions ⇒ Object (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 |
#key ⇒ Object (readonly)
Returns the value of attribute key.
10 11 12 |
# File 'app/components/satis/card/component.rb', line 10 def key @key end |
#menu ⇒ Object (readonly)
Returns the value of attribute menu.
10 11 12 |
# File 'app/components/satis/card/component.rb', line 10 def @menu end |
#persist ⇒ Object (readonly)
Returns the value of attribute persist.
10 11 12 |
# File 'app/components/satis/card/component.rb', line 10 def persist @persist end |
#scope=(value) ⇒ Object (writeonly)
Sets the attribute scope
11 12 13 |
# File 'app/components/satis/card/component.rb', line 11 def scope=(value) @scope = value end |
Instance Method Details
#custom_tabs_link(&block) ⇒ Object
63 64 65 66 67 68 |
# File 'app/components/satis/card/component.rb', line 63 def custom_tabs_link(&block) return @custom_tabs_link unless block_given? @custom_tabs_link = block.call # @custom_tabs_link_html = block.call.html_safe end |
#header? ⇒ Boolean
70 71 72 |
# File 'app/components/satis/card/component.rb', line 70 def header? icon.present? || title.present? || description.present? || end |
#title ⇒ Object
def key
return unless @persist
@key ||= identifier.to_s.parameterize.underscore if identifier.present?
@key ||= (@title)&.parameterize&.underscore
[controller_name, action_name, params[:id], @key, 'tab'].compact.join('_')
end
57 58 59 60 61 |
# File 'app/components/satis/card/component.rb', line 57 def title return @title if @title @title ||= ct('.title') end |