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