Module: Maquina::ApplicationView

Instance Method Summary collapse

Instance Method Details

#attribute_human_name(attribute) ⇒ Object



42
43
44
# File 'app/views/maquina/application_view.rb', line 42

def attribute_human_name(attribute)
  resource_class.human_attribute_name(attribute)
end

#button_to(name, options = nil, html_options = nil) ⇒ Object



19
20
21
# File 'app/views/maquina/application_view.rb', line 19

def button_to(name, options = nil, html_options = nil)
  unsafe_raw helpers.button_to(name, options, html_options)
end

#image_tag(source, options = {}) ⇒ Object

TODO: Revisit this later



11
12
13
# File 'app/views/maquina/application_view.rb', line 11

def image_tag(source, options = {})
  unsafe_raw helpers.image_tag(source, **options)
end


15
16
17
# File 'app/views/maquina/application_view.rb', line 15

def link_to(body, url, html_options = {})
  unsafe_raw helpers.link_to(body, url, html_options)
end

#model_human_name(plural: false) ⇒ Object



38
39
40
# File 'app/views/maquina/application_view.rb', line 38

def model_human_name(plural: false)
  resource_class.model_name.human(count: plural ? 2 : 1)
end

#svg_icon(type, icon:, view_box: "0 0 24 24", stroke_width: 2, css_class: "block h-6 w-6", data: {}) ⇒ Object

type: :fill or :outline



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/views/maquina/application_view.rb', line 24

def svg_icon(type, icon:, view_box: "0 0 24 24", stroke_width: 2, css_class: "block h-6 w-6", data: {})
  svg_attributes = if type == :fill
    {xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", viewBox: view_box, "aria-hidden": "true"}
  else
    {xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: view_box, "stroke-width": stroke_width, stroke: "currentColor", "aria-hidden": "true"}
  end

  path_attributes = (type == :fill) ? {} : {"stroke-linecap": "round", "stroke-linejoin": "round"}

  svg(class: css_class, data: data, **svg_attributes) do |markup|
    markup.path(d: icon, **path_attributes)
  end
end