Module: Wallaby::StylingHelper

Included in:
BaseHelper
Defined in:
lib/helpers/wallaby/styling_helper.rb

Overview

Styling helper

Instance Method Summary collapse

Instance Method Details

#fa_icon(icon_suffix, html_options = {}, &block) ⇒ String

Shortcut for fontawesome icons

Parameters:

  • icon_suffix (String)
  • html_options (Hash) (defaults to: {})

Returns:

  • (String)

    HTML I element



15
16
17
18
19
20
# File 'lib/helpers/wallaby/styling_helper.rb', line 15

def fa_icon(icon_suffix, html_options = {}, &block)
  html_options[:class] = Array html_options[:class]
  html_options[:class] << "fa fa-#{icon_suffix}"

   :i, nil, html_options, &block
end

#html_classes(string_or_array) ⇒ Hash

Shortcut to build up the html options as keyword arguments

Parameters:

  • string_or_array (String, Array)

Returns:

  • (Hash)


7
8
9
# File 'lib/helpers/wallaby/styling_helper.rb', line 7

def html_classes(string_or_array)
  { html_options: { class: string_or_array } }
end

#imodal(title, body, html_options = {}) ⇒ String

Build up modal

Parameters:

  • title (String)
  • body (String)
  • html_options (Hash) (defaults to: {})

Returns:

  • (String)

    modal HTML



39
40
41
42
43
44
45
46
47
# File 'lib/helpers/wallaby/styling_helper.rb', line 39

def imodal(title, body, html_options = {})
  label ||= html_options.delete(:label) \
              || html_options.delete(:icon) || fa_icon('clone')
   :span, class: 'modaler' do
    concat link_to(label, '#', data: { target: '#imodal', toggle: 'modal' })
    concat (:span, title, class: 'modaler__title')
    concat (:span, body, class: 'modaler__body')
  end
end

#itooltip(title, icon_suffix = 'info-circle', html_options = {}) ⇒ String

Build up tooltip

Parameters:

  • title (String)
  • icon_suffix (String) (defaults to: 'info-circle')
  • html_options (Hash) (defaults to: {})

Returns:

  • (String)

    tooltip HTML



27
28
29
30
31
32
# File 'lib/helpers/wallaby/styling_helper.rb', line 27

def itooltip(title, icon_suffix = 'info-circle', html_options = {})
  html_options[:title] = title
  (html_options[:data] ||= {}).merge! toggle: 'tooltip', placement: 'top'

  fa_icon icon_suffix, html_options
end

#muted(text_content) ⇒ String

Grey text

Parameters:

  • text_content (String)

Returns:

  • (String)

    HTML I element



62
63
64
# File 'lib/helpers/wallaby/styling_helper.rb', line 62

def muted(text_content)
   :i, "<#{text_content}>", class: 'text-muted'
end

#naString

Returns grey N/A.

Returns:

  • (String)

    grey N/A



55
56
57
# File 'lib/helpers/wallaby/styling_helper.rb', line 55

def na
  muted 'n/a'
end

#nullString

Returns grey null.

Returns:

  • (String)

    grey null



50
51
52
# File 'lib/helpers/wallaby/styling_helper.rb', line 50

def null
  muted 'null'
end