Class: UiBibz::Ui::Core::Component

Inherits:
Base
  • Object
show all
Includes:
GlyphExtension, KlassExtension
Defined in:
lib/ui_bibz/ui/core/component.rb

Overview

Creates a component of the given name using options created by the set of options.

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:

  • status - status of element with symbol value: (:primary, :secondary, :success, :info, :warning, :danger, :light, :dark)

  • glyph - Add glyph with name or hash options

    • name - String

    • size - Integer

    • type - Symbol

Signatures

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

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

Examples

UiBibz::Ui::Core::Component.new(content, { type: :success, glyph: 'eye' }, { class: 'test' })
# or
UiBibz::Ui::Core::Component.new({glyph: { name: 'eye', size: 3}, { class: 'test' }) do
  content
end

Direct Known Subclasses

Boxes::Card, Boxes::CardAccordion, Boxes::CardColumn, Boxes::CardDeck, Boxes::CardGroup, Boxes::Components::Body::CardBodyLink, Boxes::Components::Body::CardBodySubtitle, Boxes::Components::Body::CardBodyText, Boxes::Components::Body::CardBodyTitle, Boxes::Components::CardBody, Boxes::Components::CardFooter, Boxes::Components::CardHeader, Boxes::Components::CardImage, Boxes::Jumbotron, Forms::Buttons::Button, Forms::Buttons::ButtonGroup, Forms::Choices::BoxSwitchField, Forms::Choices::CheckboxField, Forms::Dates::DatePickerField, Forms::Dropdowns::Components::DropdownDropdown, Forms::Dropdowns::Components::DropdownHeader, Forms::Dropdowns::Dropdown, Forms::Files::FileField, Forms::Numbers::FormulaField, Forms::Numbers::SliderHeader, Forms::Selects::AbstractSelect, Forms::Surrounds::SurroundAddon, Forms::Surrounds::SurroundField, Forms::Textareas::MarkdownEditorField, Forms::Texts::TextField, Icons::Components::GlyphText, Icons::Glyph, Icons::Star, Layouts::Col, Layouts::Container, Layouts::Row, Lists::Components::List, Lists::Components::ListBody, Lists::Components::ListHeader, Lists::ListGroup, Navigations::Breadcrumb, Navigations::Link, Navigations::Nav, Navigations::NavLink, Navigations::NavLinkLink, Navigations::NavLinkList, Navigations::NavLinkSpan, Navigations::NavText, Navigations::Navbar, Navigations::NavbarBrand, Navigations::NavbarText, Navigations::Pagination, Navigations::PaginationLink, Navigations::Toolbar, Notifications::Alert, Notifications::Badge, Notifications::Components::AlertBody, Notifications::Components::AlertHeader, Notifications::Components::Bar, Notifications::Components::ToastBody, Notifications::Components::ToastHeader, Notifications::Popover, Notifications::ProgressBar, Notifications::Spinner, Notifications::Toast, Notifications::Tooltip, Windows::Components::ModalBody, Windows::Components::ModalFooter, Windows::Components::ModalHeader, Windows::Components::OffcanvasBody, Windows::Components::OffcanvasHeader, Windows::Modal, Windows::Offcanvas, Ux::Containers::Components::PanelBody, Ux::Containers::Components::PanelColumn, Ux::Containers::Components::PanelDeck, Ux::Containers::Components::PanelFooter, Ux::Containers::Components::PanelGroup, Ux::Containers::Components::PanelHeader, Ux::Containers::Components::PanelHeaderTitle, Ux::Containers::Panel, Ux::Tables::Column, Ux::Tables::Table, Ux::Tables::TableSearchField, Ux::Tables::Thead

Constant Summary collapse

STATUSES =

Constants

%i[primary secondary success danger warning info light dark].freeze
BREAKPOINTS =
%i[xxl xl lg md sm xs].freeze
SIZES =
%i[lg md sm].freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#output_buffer

Instance Method Summary collapse

Methods included from GlyphExtension

#glyph_and_content_html

Methods included from KlassExtension

#exclude_classes, #exclude_classes_in_html_options, #join_classes, #status

Methods inherited from Base

#generate_id, #i18n_set?, #inject_url

Constructor Details

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

Use link_to system in rails

  • Content can be send by content variable or by block if a block is sent, variable ‘content’ does not exit.

  • Options of component is defined in hash options

  • Html options is defined in hash html_options



59
60
61
62
63
64
65
66
67
68
69
# File 'lib/ui_bibz/ui/core/component.rb', line 59

def initialize(content = nil, options = nil, html_options = nil, &block)
  component_initialize_factory_method = UiBibz::FactoryMethods::ComponentInitializeFactoryMethod.new(self, self.binding).make
  @content = component_initialize_factory_method.content
  @html_options = component_initialize_factory_method.html_options
  @options      = component_initialize_factory_method.options

  @data_html_options_builder = UiBibz::Builders::DataHtmlOptionsBuilder.new(@content, @options, @html_options)

  init_options
  init_component_html_options
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



52
53
54
# File 'lib/ui_bibz/ui/core/component.rb', line 52

def content
  @content
end

#html_optionsObject

Returns the value of attribute html_options.



52
53
54
# File 'lib/ui_bibz/ui/core/component.rb', line 52

def html_options
  @html_options
end

#optionsObject

Returns the value of attribute options.



52
53
54
# File 'lib/ui_bibz/ui/core/component.rb', line 52

def options
  @options
end

Instance Method Details

#pre_renderObject

Render without cache



77
78
79
# File 'lib/ui_bibz/ui/core/component.rb', line 77

def pre_render
  glyph_and_content_html
end

#renderObject

Render html tag with or without cache



72
73
74
# File 'lib/ui_bibz/ui/core/component.rb', line 72

def render
  render_with_or_without_cache
end