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
- #attribute_block(hash) ⇒ Object
- #attribute_tag(label, content) ⇒ Object
- #collapsed_css_property_if(tru) ⇒ Object
-
#color_tag(css_color = nil, value) ⇒ Object
TODO: make the color an attribute and apply it after, give a border.
-
#data_tag(content) ⇒ String
Wrap content in a span, and give it a :data class.
- #hidden_css_property_if(tru) ⇒ Object
- #scrollable_div_tag(text) ⇒ Object
- #toggle_class_css(css_class, boolean) ⇒ Object
-
#turbolinks_off_tag ⇒ Object
Set @no_turbolinks in a before_action, then use the method in, say a layout.
Instance Method Details
#attribute_block(hash) ⇒ Object
45 46 47 |
# File 'app/helpers/workbench/style_helper.rb', line 45 def attribute_block(hash) hash.collect{|label, content| attribute_tag(label, content)}.join.html_safe end |
#attribute_tag(label, content) ⇒ Object
38 39 40 41 42 43 |
# File 'app/helpers/workbench/style_helper.rb', line 38 def attribute_tag(label, content) content_tag(:p) do content_tag(:strong, label) + ' ' + data_tag(content) end end |
#collapsed_css_property_if(tru) ⇒ Object
15 16 17 |
# File 'app/helpers/workbench/style_helper.rb', line 15 def collapsed_css_property_if(tru) tru ? 'collapsed'.html_safe : nil end |
#color_tag(css_color = nil, value) ⇒ Object
TODO: make the color an attribute and apply it after, give a border
50 51 52 53 |
# File 'app/helpers/workbench/style_helper.rb', line 50 def color_tag(css_color = nil, value) return value if css_color.nil? content_tag(:span, value, style: "background-color: #{css_color};") end |
#data_tag(content) ⇒ String
Wrap content in a span, and give it a :data class
34 35 36 |
# File 'app/helpers/workbench/style_helper.rb', line 34 def data_tag(content) content_tag(:span, content, class: :data) end |
#hidden_css_property_if(tru) ⇒ Object
11 12 13 |
# File 'app/helpers/workbench/style_helper.rb', line 11 def hidden_css_property_if(tru) tru ? 'hidden'.html_safe : nil end |
#scrollable_div_tag(text) ⇒ Object
6 7 8 9 |
# File 'app/helpers/workbench/style_helper.rb', line 6 def scrollable_div_tag(text) return nil if text.blank? content_tag(:div, text, class: 'scrollable_div one_third') end |
#toggle_class_css(css_class, boolean) ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/helpers/workbench/style_helper.rb', line 24 def toggle_class_css(css_class, boolean) if boolean css_class else nil end end |
#turbolinks_off_tag ⇒ Object
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 |