Class: BetterUi::General::Table::TrComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Table::TrComponent
- Defined in:
- app/components/better_ui/general/table/tr_component.rb
Instance Attribute Summary collapse
-
#highlighted ⇒ Object
readonly
Returns the value of attribute highlighted.
-
#striped_index ⇒ Object
readonly
Returns the value of attribute striped_index.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(theme: :default, highlighted: false, striped_index: nil, **html_options) ⇒ TrComponent
constructor
A new instance of TrComponent.
- #tr_attributes ⇒ Object
- #tr_classes ⇒ Object
Constructor Details
#initialize(theme: :default, highlighted: false, striped_index: nil, **html_options) ⇒ TrComponent
Returns a new instance of TrComponent.
7 8 9 10 11 12 |
# File 'app/components/better_ui/general/table/tr_component.rb', line 7 def initialize(theme: :default, highlighted: false, striped_index: nil, **) @theme = theme.to_sym @highlighted = !!highlighted @striped_index = striped_index @html_options = end |
Instance Attribute Details
#highlighted ⇒ Object (readonly)
Returns the value of attribute highlighted.
5 6 7 |
# File 'app/components/better_ui/general/table/tr_component.rb', line 5 def highlighted @highlighted end |
#striped_index ⇒ Object (readonly)
Returns the value of attribute striped_index.
5 6 7 |
# File 'app/components/better_ui/general/table/tr_component.rb', line 5 def striped_index @striped_index end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
5 6 7 |
# File 'app/components/better_ui/general/table/tr_component.rb', line 5 def theme @theme end |
Instance Method Details
#tr_attributes ⇒ Object
22 23 24 25 26 |
# File 'app/components/better_ui/general/table/tr_component.rb', line 22 def tr_attributes attrs = @html_options.except(:class) attrs[:class] = tr_classes attrs end |
#tr_classes ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/components/better_ui/general/table/tr_component.rb', line 14 def tr_classes [ "border-b border-gray-100", @highlighted ? "bg-blue-50" : nil, @html_options[:class] ].compact.join(" ") end |