Class: ExpressAdmin::LayoutComponent

Inherits:
ExpressTemplates::Components::Configurable
  • Object
show all
Defined in:
app/components/express_admin/layout_component.rb

Direct Known Subclasses

HBox, Pane, SidebarRegion, VBox

Instance Method Summary collapse

Instance Method Details

#component_classes ⇒ Object



12
13
14
15
16
# File 'app/components/express_admin/layout_component.rb', line 12

def component_classes
  add_class config[:id].to_s
  add_class config[:class]
  class_names
end

#component_options ⇒ Object



8
9
10
# File 'app/components/express_admin/layout_component.rb', line 8

def component_options
  [:id, :class, :style] + supported_style_options
end

#container_div_attributes ⇒ Object



37
38
39
40
41
# File 'app/components/express_admin/layout_component.rb', line 37

def container_div_attributes
  pass_along_attributes
    .merge(id: dom_id, class: component_classes)
    .merge(style: style_attributes)
end

#dom_id ⇒ Object



4
5
6
# File 'app/components/express_admin/layout_component.rb', line 4

def dom_id
  config.try(:[], :id)
end

#pass_along_attributes ⇒ Object



33
34
35
# File 'app/components/express_admin/layout_component.rb', line 33

def pass_along_attributes
  config.reject {|k,v| component_options.include?(k) }
end

#provided_style_attributes ⇒ Object



22
23
24
# File 'app/components/express_admin/layout_component.rb', line 22

def provided_style_attributes
  config.select {|k,v| supported_style_options.include?(k) }
end

#style_attributes ⇒ Object



26
27
28
29
30
31
# File 'app/components/express_admin/layout_component.rb', line 26

def style_attributes
  attribs = config[:style] || {}
  attribs.merge(provided_style_attributes).map do |k, v|
    "#{k}: #{v}"
  end.join('; ')
end

#supported_style_options ⇒ Object



18
19
20
# File 'app/components/express_admin/layout_component.rb', line 18

def supported_style_options
  [:height, :width]
end