Module: Card::Set::All::Bootstrap::Navbar::HtmlFormat

Extended by:
Card::Set::AbstractFormat
Defined in:
card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/navbar.rb,
card/tmpsets/set/mod022-card-mod-bootstrap/all/bootstrap/navbar.rb

Instance Method Summary collapse

Instance Method Details

Options

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

  • brand (String, Hash<name, href>)
  • class (String)
  • no_collapse (Boolean)
  • toggle_align (:left, :right)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/navbar.rb', line 17

def navbar id, opts={}
  nav_opts = opts[:navbar_opts] || {}
  nav_opts[:class] ||= opts[:class]
  add_class nav_opts,
            "navbar navbar-dark bg-#{opts.delete(:navbar_type) || 'primary'}"
  content = yield
  if opts[:no_collapse]
    navbar_nocollapse content, nav_opts
  else
    navbar_responsive id, content, opts, nav_opts
  end
end


47
48
49
50
51
52
53
54
55
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/navbar.rb', line 47

def navbar_header brand
  return "" unless brand
  if brand.is_a? String
    "<span class='navbar-brand'>#{brand}</span>"
  else
    link = brand[:href] || "#"
    "<a class='navbar-brand' href='#{link}#'>#{brand[:name]}</a>"
  end
end


57
58
59
60
61
62
63
64
# File 'card/tmpsets/set/mod021-card-mod-bootstrap/all/bootstrap/navbar.rb', line 57

def navbar_toggle id, align
  content ||= %(<span class="navbar-toggler-icon"></span>)
  <<-HTML
    <button class="navbar-toggler navbar-toggler-#{align}" type="button" data-toggle="collapse" data-target="#navbar-collapse-#{id}" aria-controls="navbar-collapse-#{id}" aria-expanded="false" aria-label="Toggle navigation">
        #{content}
    </button>
  HTML
end