Class: BetterUi::General::Table::TdComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- BetterUi::General::Table::TdComponent
- Defined in:
- app/components/better_ui/general/table/td_component.rb
Instance Attribute Summary collapse
-
#align ⇒ Object
readonly
Returns the value of attribute align.
-
#compact ⇒ Object
readonly
Returns the value of attribute compact.
-
#theme ⇒ Object
readonly
Returns the value of attribute theme.
Instance Method Summary collapse
-
#initialize(theme: :default, align: :left, compact: false, **html_options) ⇒ TdComponent
constructor
A new instance of TdComponent.
- #td_attributes ⇒ Object
- #td_classes ⇒ Object
Constructor Details
#initialize(theme: :default, align: :left, compact: false, **html_options) ⇒ TdComponent
Returns a new instance of TdComponent.
7 8 9 10 11 12 |
# File 'app/components/better_ui/general/table/td_component.rb', line 7 def initialize(theme: :default, align: :left, compact: false, **) @theme = theme.to_sym @align = align.to_sym @compact = !!compact @html_options = end |
Instance Attribute Details
#align ⇒ Object (readonly)
Returns the value of attribute align.
5 6 7 |
# File 'app/components/better_ui/general/table/td_component.rb', line 5 def align @align end |
#compact ⇒ Object (readonly)
Returns the value of attribute compact.
5 6 7 |
# File 'app/components/better_ui/general/table/td_component.rb', line 5 def compact @compact end |
#theme ⇒ Object (readonly)
Returns the value of attribute theme.
5 6 7 |
# File 'app/components/better_ui/general/table/td_component.rb', line 5 def theme @theme end |
Instance Method Details
#td_attributes ⇒ Object
23 24 25 26 27 |
# File 'app/components/better_ui/general/table/td_component.rb', line 23 def td_attributes attrs = @html_options.except(:class) attrs[:class] = td_classes attrs end |
#td_classes ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'app/components/better_ui/general/table/td_component.rb', line 14 def td_classes [ "px-4 py-3 text-sm text-gray-900", alignment_class, @compact ? "py-1" : nil, @html_options[:class] ].compact.join(" ") end |