Class: ActiveAdmin::Views::Columns
- Inherits:
-
Component
- Object
- Arbre::HTML::Div
- Component
- ActiveAdmin::Views::Columns
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/active_admin/views/components/columns.rb', line 27
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
23
24
25
|
# File 'lib/active_admin/views/components/columns.rb', line 23
def margin_size
2
end
|
#to_s ⇒ Object
17
18
19
|
# File 'lib/active_admin/views/components/columns.rb', line 17
def to_s
super.to_s + "<div style=\"clear:both;\"></div>".html_safe
end
|