Class: NitroKit::Table
- Defined in:
- app/components/nitro_kit/table.rb
Instance Attribute Summary collapse
-
#wrapper ⇒ Object
readonly
Returns the value of attribute wrapper.
Attributes inherited from Component
Instance Method Summary collapse
- #html_tbody ⇒ Object
- #html_td ⇒ Object
- #html_th ⇒ Object
- #html_thead ⇒ Object
- #html_tr ⇒ Object
-
#initialize(wrapper: {}, **attrs) ⇒ Table
constructor
A new instance of Table.
- #tbody(**attrs) ⇒ Object
- #td(text = nil, align: nil, **attrs, &block) ⇒ Object
- #th(text = nil, align: :left, **attrs, &block) ⇒ Object
- #thead(**attrs) ⇒ Object
- #tr(**attrs) ⇒ Object
- #view_template ⇒ Object
Methods inherited from Component
Constructor Details
#initialize(wrapper: {}, **attrs) ⇒ Table
Returns a new instance of Table.
5 6 7 8 |
# File 'app/components/nitro_kit/table.rb', line 5 def initialize(wrapper: {}, **attrs) super(attrs) @wrapper = wrapper end |
Instance Attribute Details
#wrapper ⇒ Object (readonly)
Returns the value of attribute wrapper.
10 11 12 |
# File 'app/components/nitro_kit/table.rb', line 10 def wrapper @wrapper end |
Instance Method Details
#html_tbody ⇒ Object
26 |
# File 'app/components/nitro_kit/table.rb', line 26 alias :html_tbody :tbody |
#html_td ⇒ Object
29 |
# File 'app/components/nitro_kit/table.rb', line 29 alias :html_td :td |
#html_th ⇒ Object
28 |
# File 'app/components/nitro_kit/table.rb', line 28 alias :html_th :th |
#html_thead ⇒ Object
25 |
# File 'app/components/nitro_kit/table.rb', line 25 alias :html_thead :thead |
#html_tr ⇒ Object
27 |
# File 'app/components/nitro_kit/table.rb', line 27 alias :html_tr :tr |
#tbody(**attrs) ⇒ Object
37 38 39 40 41 |
# File 'app/components/nitro_kit/table.rb', line 37 def tbody(**attrs) builder do html_tbody(**mattr(attrs, class: "[&_tr:last-child]:border-0")) { yield } end end |
#td(text = nil, align: nil, **attrs, &block) ⇒ Object
57 58 59 60 61 62 63 |
# File 'app/components/nitro_kit/table.rb', line 57 def td(text = nil, align: nil, **attrs, &block) builder do html_td(**mattr(attrs, class: [ cell_classes, align_classes(align) ])) do text_or_block(text, &block) end end end |
#th(text = nil, align: :left, **attrs, &block) ⇒ Object
49 50 51 52 53 54 55 |
# File 'app/components/nitro_kit/table.rb', line 49 def th(text = nil, align: :left, **attrs, &block) builder do html_th(**mattr(attrs, class: [ header_cell_classes, cell_classes, align_classes(align), "font-medium" ])) do text_or_block(text, &block) end end end |
#thead(**attrs) ⇒ Object
31 32 33 34 35 |
# File 'app/components/nitro_kit/table.rb', line 31 def thead(**attrs) builder do html_thead(**attrs) { yield } end end |
#tr(**attrs) ⇒ Object
43 44 45 46 47 |
# File 'app/components/nitro_kit/table.rb', line 43 def tr(**attrs) builder do html_tr(**mattr(attrs, class: "border-b")) { yield } end end |
#view_template ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/components/nitro_kit/table.rb', line 12 def view_template div(**mattr(wrapper, class: "w-full overflow-x-scroll")) do table( **mattr( attrs, class: "w-full caption-bottom text-sm divide-y" ) ) do yield end end end |