Sha256: 56cc1611eb73f3f4e06154bd20273e7bb0a73259dfbc34f373642cbc51d3ceeb
Contents?: true
Size: 1.41 KB
Versions: 8
Compression:
Stored size: 1.41 KB
Contents
# frozen_string_literal: true module Bulmacomp # Make an html structure for a bulma breadcrumb # # @example Empty panel: # render Bulmacomp::PanelComponent.new() # # <nav class="panel"> # </nav> # # @example panel with option: # = render Bulmacomp::PanelComponent.new(title: 'test title') do # <a class="panel-block is-active"> # <span class="panel-icon"><i class="fas fa-book" aria-hidden="true"></i></span> # bulma # </a> # # <nav class="panel"> # <p class="panel-heading">test title</p> # <a class="panel-block is-active"> # <span class="panel-icon"><i class="fas fa-book" aria-hidden="true"></i></span> # bulma # </a> # </nav> class PanelComponent < ViewComponent::Base # @param [Hash] opts # options to generate content # @option opts [String] :title # panel title # @option opts [String] :* # each other key going as tag option, default is class: 'panel' # @yield [optional] # panel content def initialize(title: nil, **opts) super @title = title @opts = { class: 'panel' }.merge(opts) end # return [String] html_safe generated bulma panel def call content_tag :nav, safe_join([title, content]), **@opts end # return [String] html_safe generated panel title def title tag.p @title, class: 'panel-heading' if @title end end end
Version data entries
8 entries across 8 versions & 1 rubygems