Class: Fluxbit::TableComponent
- Includes:
- Config::TableComponent
- Defined in:
- app/components/fluxbit/table_component.rb
Overview
The ‘Fluxbit::TableComponent` is a customizable alert component that extends `Fluxbit::Component`. It provides various options to display alert messages with different styles, icons, and behaviors such as close functionality and animations.
Example usage:
= render Fluxbit::TableComponent.new(
striped: true,
bordered: true,
hover: true,
shadow: true,
wrapper_html: { class: "my-custom-wrapper" },
thead_html: { class: "my-custom-thead" },
tbody_html: { class: "my-custom-tbody" },
tr_html: { class: "my-custom-tr" }
) do |table|
table.with_header do |header|
header.with_column "Column 1"
header.with_column "Column 2"
end
table.with_row do |row|
row.with_cell "Data 1"
row.with_cell "Data 2"
end
end
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ Fluxbit::TableComponent
constructor
Initializes the table component with the given properties.
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #icon, #options, #popover?, #random_id, #remove_class, #remove_class_from_props, #render_popover_or_tooltip, #target, #tooltip?
Methods included from IconHelpers
#chevron_double_left, #chevron_double_right, #chevron_down, #chevron_left, #chevron_right, #chevron_up, #close_icon, #ellipsis_horizontal, #eye_icon, #eye_slash_icon, #plus_icon
Constructor Details
#initialize(**props) ⇒ Fluxbit::TableComponent
Initializes the table component with the given properties.
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'app/components/fluxbit/table_component.rb', line 116 def initialize(**props) super @props = props @striped = @props.delete(:striped), default: @@striped @bordered = @props.delete(:bordered), default: @@bordered @hover = @props.delete(:hover), default: @@hover @shadow = @props.delete(:shadow), default: @@shadow @only_rows = @props.delete(:only_rows), default: false # Wrapper HTML @wrapper_html = @props.delete(:wrapper_html) || {} add(class: styles[:wrapper][:base], to: @wrapper_html) add(class: styles[:wrapper][:shadow], to: @wrapper_html) if @shadow # Head HTML @thead_html = @props.delete(:thead_html) || {} # add(class: styles[:head][:base], to: @thead_html) # Body HTML @tbody_html = @props.delete(:tbody_html) || {} add(class: styles[:body][:base], to: @tbody_html) # Row HTML @tr_html = @props.delete(:tr_html) || {} add(class: styles[:body][:base], to: @tbody_html) # Footer HTML @tfoot_html = @props.delete(:tfoot_html) || {} add(class: styles[:footer][:base], to: @tfoot_html) # Table HTML add(class: styles[:root][:base], to: @props) end |
Instance Method Details
#call ⇒ Object
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'app/components/fluxbit/table_component.rb', line 150 def call return safe_join(rows) if @only_rows && rows? # Wrapper capture do # Table concat(tag.div(**@wrapper_html) do concat(tag.table(**@props) do # header concat( tag.thead(**@thead_html) do concat(safe_join headers) end ) if headers? # body concat( tag.tbody(**@tbody_html) do if content.present? content else concat(safe_join(rows)) if rows? end end ) # Footer concat( tag.tfoot(**@tfoot_html) do concat() end ) if end) end) end end |