Sha256: 124a1d6c2fe8a1d96d1bd4d527c9637f5e7ce0a1e5356bb7ce33886841d7d12d
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 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: 'breadcrumb', aria_label: 'breadcrumbs' # @yield [optional] # panel content def initialize(title: nil, **opts) super @title = title @opts = opts @opts[:class] = 'panel' unless @opts[:class] 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bulmacomp-0.1.1 | app/components/bulmacomp/panel_component.rb |
bulmacomp-0.1.0 | app/components/bulmacomp/panel_component.rb |