Class: NitroKit::Table
Instance Attribute Summary collapse
Attributes inherited from Component
#attrs
Instance Method Summary
collapse
Methods inherited from Component
#builder, builder_method, from_template
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
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: [ , 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
|