Module: Workbench::StyleHelper

Defined in:
app/helpers/workbench/style_helper.rb

Overview

Helpers that add/wrap information in CSS/SCSS, or are related to adding attributes to CSS. Also includes 'data-' related functionality.

Instance Method Summary (collapse)

Instance Method Details

- (Object) attribute_block(hash)



52
53
54
# File 'app/helpers/workbench/style_helper.rb', line 52

def attribute_block(hash)
  hash.collect{|label, content| attribute_tag(label, content)}.join.html_safe
end

- (Object) attribute_tag(label, content)



45
46
47
48
49
50
# File 'app/helpers/workbench/style_helper.rb', line 45

def attribute_tag(label, content)
  (:p) do
    (:strong, label) + ' ' +
      data_tag(content)
  end
end

- (Object) collapsed_css_property_if(tru)



15
16
17
# File 'app/helpers/workbench/style_helper.rb', line 15

def collapsed_css_property_if(tru)
  tru ? 'collapsed'.html_safe : nil
end

- (String) data_tag(content)

Wrap content in a span, and give it a :data class

Returns:

  • (String)


41
42
43
# File 'app/helpers/workbench/style_helper.rb', line 41

def data_tag(content)
  (:span, content, class: :data)
end

- (Object) hidden_css_property_if(tru)



11
12
13
# File 'app/helpers/workbench/style_helper.rb', line 11

def hidden_css_property_if(tru)
  tru ? 'hidden'.html_safe : nil
end

- (Object) scrollable_div_tag(text)



6
7
8
9
# File 'app/helpers/workbench/style_helper.rb', line 6

def scrollable_div_tag(text)
  return nil if text.blank?
  (:div, text, class: 'scrollable_div one_third')
end

- (Object) toggle_class_css(css_class, boolean)

def muted_red_css(boolean)

if boolean
  ' muted_red'
else
  nil
end

end



31
32
33
34
35
36
37
# File 'app/helpers/workbench/style_helper.rb', line 31

def toggle_class_css(css_class, boolean)
  if boolean
    css_class
  else
    nil
  end
end

Set @no_turbolinks in a before_action, then use the method in, say a layout.



20
21
22
# File 'app/helpers/workbench/style_helper.rb', line 20

def turbolinks_off_tag
  'data-no-turbolink="true"'.html_safe if @no_turbolinks
end