Class: RubyUI::DataTableColumnToggle
- Defined in:
- lib/ruby_ui/data_table/data_table_column_toggle.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(columns:, **attrs) ⇒ DataTableColumnToggle
constructor
A new instance of DataTableColumnToggle.
- #view_template ⇒ Object
Constructor Details
#initialize(columns:, **attrs) ⇒ DataTableColumnToggle
Returns a new instance of DataTableColumnToggle.
5 6 7 8 |
# File 'lib/ruby_ui/data_table/data_table_column_toggle.rb', line 5 def initialize(columns:, **attrs) @columns = columns super(**attrs) end |
Instance Method Details
#view_template ⇒ Object
10 11 12 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 47 48 49 50 51 |
# File 'lib/ruby_ui/data_table/data_table_column_toggle.rb', line 10 def view_template div(**attrs) do render RubyUI::DropdownMenu.new do render RubyUI::DropdownMenuTrigger.new do render RubyUI::Button.new(variant: :outline, size: :sm) do plain "Columns" # inline chevron-down SVG (lucide 24px, 1px stroke) svg( xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", stroke_width: "2", stroke_linecap: "round", stroke_linejoin: "round", class: "w-4 h-4 ml-1" ) do |s| s.polyline(points: "6 9 12 15 18 9") end end end render RubyUI::DropdownMenuContent.new do @columns.each do |col| label(class: "flex items-center gap-2 rounded-sm px-2 py-1.5 text-sm cursor-pointer hover:bg-accent") do input( type: "checkbox", checked: true, class: "h-4 w-4 rounded border border-input accent-primary cursor-pointer", data: { column_key: col[:key].to_s, action: "change->ruby-ui--data-table-column-visibility#toggle" } ) span { plain col[:label] } end end end end end end |