class UiBibz::Ui::Core::Boxes::Card

Create a card

This element is an extend of UiBibz::Ui::Core::Component.

Attributes

Options

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

Signatures

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

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

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

Examples

UiBibz::Ui::Core::Boxes::Card('test').render

UiBibz::Ui::Core::Boxes::Card(status: :primary) do |d|
  'test'
end.render

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

Helper

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

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

card(options = {}, 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

Public Class Methods

new(content = nil, options = nil, html_options = nil, &block) click to toggle source

(see UiBibz::Ui::Core::Component#initialize)

Calls superclass method UiBibz::Ui::Core::Component::new
# File lib/ui_bibz/ui/core/boxes/card.rb, line 95
def initialize(content = nil, options = nil, html_options = nil, &block)
  super
  @items = @content.nil? ? [] : [UiBibz::Ui::Core::Boxes::Components::CardBody.new(@content).render]
end

Public Instance Methods

pre_render() click to toggle source

Render html tag

# File lib/ui_bibz/ui/core/boxes/card.rb, line 101
def pre_render
  content_tag :div, html_structure, html_options
end

Protected Instance Methods

card_block() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 127
def card_block
  'card-block' if !@options[:block].nil? || @tapped
end
component_html_classes() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 111
def component_html_classes
  ['card', text, type, tab_pane, outline, tabbed]
end
html_structure() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 107
def html_structure
  [@header, @items.join, @footer].compact.join.html_safe
end
outline() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 143
def outline
  'bg-transparent' if @options[:outline]
end
status() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 115
def status
  return if @options[:status].nil?

  output = @options[:outline] ? ["border-#{@options[:status]}"] : ["bg-#{@options[:status]}"]
  output << 'text-white' if @options[:status] != :light && @options[:status] != :warning
  output.join(' ')
end
tab_pane() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 135
def tab_pane
  'tab-pane' if @options[:tab]
end
tabbed() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 139
def tabbed
  'tab-content' if @options[:tabbed]
end
text() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 123
def text
  "text-#{@options[:text][:size] || :md}-#{@options[:text][:position] || :left}" unless @options[:text].nil?
end
type() click to toggle source
# File lib/ui_bibz/ui/core/boxes/card.rb, line 131
def type
  "card-#{@options[:type]}" unless @options[:type].nil?
end