Class: Tungsten::CardHelper::Card
- Defined in:
- app/helpers/tungsten/card_helper.rb
Instance Method Summary collapse
- #actions(options = {}, &block) ⇒ Object
- #description(text = nil, options = {}, &block) ⇒ Object
- #display(body) ⇒ Object
- #divider(options = {}) ⇒ Object
- #footer(text = nil, options = {}, &block) ⇒ Object
- #header(text = nil, options = {}, &block) ⇒ Object
-
#initialize(title = nil, options = {}) ⇒ Card
constructor
A new instance of Card.
- #well(options = {}, &block) ⇒ Object
Constructor Details
#initialize(title = nil, options = {}) ⇒ Card
Returns a new instance of Card.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'app/helpers/tungsten/card_helper.rb', line 5 def initialize( title = nil, = {} ) if title && title.is_a?(Hash) @options = title @title = nil else @options = @title = title end @options[:data] ||= {} @options[:data][:animate] ||= @options.delete(:animate) @options[:class] = "card-section #{@options.delete(:class)} #{"hidden" if @options.delete(:hidden)}".strip end |
Instance Method Details
#actions(options = {}, &block) ⇒ Object
75 76 77 78 79 |
# File 'app/helpers/tungsten/card_helper.rb', line 75 def actions( ={}, &block ) [:class] = "card-actions #{[:class]}".strip content_tag( :nav, , &block ) end |
#description(text = nil, options = {}, &block) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/tungsten/card_helper.rb', line 61 def description( text = nil, = {}, &block ) if text.is_a? Hash = text text = nil end [:class] = "card-description #{[:class]}".strip content_tag( :p, ) { concat text unless text.nil? concat capture(&block).html_safe if block_given? } end |
#display(body) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/helpers/tungsten/card_helper.rb', line 18 def display( body ) content_tag( :section, @options ) do content_tag( :div, class: 'card-wrapper toggle-drawer' ) { content_tag( :div, class: 'card' ) { concat header( @title ) if @title if first_header = body.scan(/\A<header.+?header>/m).first concat first_header.html_safe body = body.sub(first_header, '').html_safe end concat content_tag(:div, class: 'card-content') { body } } } end end |
#divider(options = {}) ⇒ Object
87 88 89 90 91 92 |
# File 'app/helpers/tungsten/card_helper.rb', line 87 def divider( ={} ) [:class] = "card-divider #{[:class]}".strip tag.span() end |
#footer(text = nil, options = {}, &block) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/tungsten/card_helper.rb', line 47 def ( text = nil, = {}, &block ) if text.is_a? Hash = text text = nil end [:class] = "card-footer #{[:class]}".strip content_tag( :footer, ) { concat content_tag( :p, text ) unless text.nil? concat capture(&block).html_safe if block_given? } end |
#header(text = nil, options = {}, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'app/helpers/tungsten/card_helper.rb', line 33 def header( text = nil, = {}, &block ) if text.is_a? Hash = text text = nil end [:class] = "card-header #{[:class]}".strip content_tag( :header, ) { concat content_tag( :h2, text, class: 'card-heading' ) if text concat capture(&block).html_safe if block_given? } end |
#well(options = {}, &block) ⇒ Object
81 82 83 84 85 |
# File 'app/helpers/tungsten/card_helper.rb', line 81 def well( ={}, &block ) [:class] = "card-well #{[:class]}".strip content_tag( :div, , &block ) end |