Class: ActiveAdmin::Views::Columns
- Inherits:
-
Component
show all
- Defined in:
- lib/active_admin/views/components/columns.rb
Instance Method Summary
collapse
Methods inherited from Component
#default_class_name, #initialize, #tag_name
Instance Method Details
#add_child ⇒ Object
Override add child to set widths
12
13
14
15
|
# File 'lib/active_admin/views/components/columns.rb', line 12
def add_child(*)
super
calculate_columns!
end
|
#calculate_columns! ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/active_admin/views/components/columns.rb', line 23
def calculate_columns!
count = children.size
margins_width = margin_size * (count - 1)
column_width = (100.00 - margins_width) / count
column_width = column_width.to_i == column_width ? column_width.to_i : column_width
children.each_with_index do |col, i|
col.set_attribute :style, "width: #{column_width}%;"
col.attr(:style) << " margin-right: #{margin_size}%;" unless i == (count - 1)
end
end
|
#column(*args, &block) ⇒ Object
7
8
9
|
# File 'lib/active_admin/views/components/columns.rb', line 7
def column(*args, &block)
insert_tag Column, *args, &block
end
|
#margin_size ⇒ Object
19
20
21
|
# File 'lib/active_admin/views/components/columns.rb', line 19
def margin_size
2
end
|
38
39
40
|
# File 'lib/active_admin/views/components/columns.rb', line 38
def to_html
super.to_s + "<div style=\"clear:both;\"></div>".html_safe
end
|