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

Extended by:
Card::Set::AbstractFormat
Defined in:
tmpsets/set/mod026-bootstrap/all/bootstrap/navbar.rb

Instance Method Summary collapse

Instance Method Details



66
67
68
69
70
71
72
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/navbar.rb', line 66

def breadcrumb items
  wrap_with :ol, class: "breadcrumb" do
    items.map do |item|
      wrap_with :li, item, class: "breadcrumb-item"
    end.join
  end
end

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 'tmpsets/set/mod026-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 'tmpsets/set/mod026-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


30
31
32
33
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/navbar.rb', line 30

def navbar_nocollapse content, nav_opts
  # content = wrap_with(:div, content)
  wrap_with :nav, content, nav_opts
end


35
36
37
38
39
40
41
42
43
44
45
# File 'tmpsets/set/mod026-bootstrap/all/bootstrap/navbar.rb', line 35

def navbar_responsive id, content, opts, nav_opts
  opts[:toggle_align] ||= :right
  wrap_with :nav, nav_opts do
    [
      navbar_header(opts[:brand]),
      navbar_toggle(id, opts[:toggle_align]),
      wrap_with(:div, class: "collapse navbar-collapse",
                id: "navbar-collapse-#{id}") { content }
    ]
  end
end


57
58
59
60
61
62
63
64
# File 'tmpsets/set/mod026-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