Class: UiBibz::Ui::Core::Panel

Inherits:
Component show all
Defined in:
lib/ui_bibz/ui/core/panel.rb

Overview

Create a panel

This element is an extend of UiBibz::Ui::Core::Component. You can use tap method to add header, body or footer element.

Attributes

  • content - Content of element

  • options - Options of element

  • html_options - Html Options of element

Options

You can add HTML attributes using the html_options. You can pass arguments in options attribute:

  • state - State of √©lement with symbol value: (:default, :primary, :info, :warning, :danger)

Signatures

UiBibz::Ui::Core::Panel.new(content, options = nil, html_options = nil)

UiBibz::Ui::Core::Panel.new(options = nil, html_options = nil) do
  content
end

UiBibz::Ui::Core::Panel.new(options = nil, html_options = nil).tap do |p|
  p.header content = nil, options = nil, html_options = nil, &block
  p.body content = nil, options = nil, html_options = nil, &block
  p.footer content = nil, options = nil, html_options = nil, &block
end

Examples

UiBibz::Ui::Core::Panel('test').render

UiBibz::Ui::Core::Panel(state: :primary) do |d|
  'test'
end.render

UiBibz::Ui::Core::Panel.new().tap do |p|
  p.header 'header', glyph: 'eye', class: 'header-test'
  p.body do
    'body'
  end
  p.footer 'footer'
end.render

Helper

panel(content, options = {}, html_options = {})

panel(options = {}, html_options = {}) do
  content
end

panel(options = { tap: true }, html_options = {}) do |p|
  p.header(content, options = {}, html_options = {})
  # or
  p.header(options = {}, html_options = {}) do
    content
  end

  p.body(content, options = {}, html_options = {})
  # or
  p.body(options = {}, html_options = {}) do
    content
  end

  p.footer(content, options = {}, html_options = {})
  # or
  p.footer(options = {}, html_options = {}) do
    content
  end
end

Direct Known Subclasses

Ux::TablePanel

Instance Attribute Summary

Attributes inherited from Component

#content, #html_options, #options

Attributes inherited from Base

#output_buffer

Instance Method Summary collapse

Methods inherited from Component

#add_classes, #badge_html, #class_and_html_options, #glyph, #glyph_and_content_html, #glyph_with_space, #options_in_html_options, #states, #status

Methods inherited from Base

#i18n_set?

Constructor Details

#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Panel


81
82
83
# File 'lib/ui_bibz/ui/core/panel.rb', line 81

def initialize content = nil, options = nil, html_options = nil, &block
  super
end

Instance Method Details

#body(content = nil, options = nil, html_options = nil, &block) ⇒ Object

Body is a component element


91
92
93
# File 'lib/ui_bibz/ui/core/panel.rb', line 91

def body content = nil, options = nil, html_options = nil, &block
  @body = Component.new content, options, html_options, &block
end

Footer is a component element


96
97
98
# File 'lib/ui_bibz/ui/core/panel.rb', line 96

def footer content = nil, options = nil, html_options = nil, &block
  @footer = Component.new content, options, html_options, &block
end

#header(content = nil, options = nil, html_options = nil, &block) ⇒ Object

Header is a component element


86
87
88
# File 'lib/ui_bibz/ui/core/panel.rb', line 86

def header content = nil, options = nil, html_options = nil, &block
  @header = Component.new content, options, html_options, &block
end

#renderObject


100
101
102
103
104
105
106
# File 'lib/ui_bibz/ui/core/panel.rb', line 100

def render
   :div, class_and_html_options("panel") do
    concat(header_html) unless @header.nil?
    concat(body_html)   if !@body.nil? || !@content.nil?
    concat(footer_html) unless @footer.nil?
  end
end

#stateObject


108
109
110
111
# File 'lib/ui_bibz/ui/core/panel.rb', line 108

def state
  sym = @options[:state] || :default
  "panel-#{ states[sym] }"
end