Class: UiBibz::Ui::Core::Component
- Includes:
- GlyphExtension, KlassExtension, PopoverExtension
- 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, = nil, = nil)
UiBibz::Ui::Core::Component.new( = nil, = 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::DropdownHeader, Forms::Dropdowns::Components::DropdownLink, 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::Modal, 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
-
#content ⇒ Object
Returns the value of attribute content.
-
#html_options ⇒ Object
Returns the value of attribute html_options.
-
#options ⇒ Object
Returns the value of attribute options.
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(content = nil, options = nil, html_options = nil, &block) ⇒ Component
constructor
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.
-
#pre_render ⇒ Object
Render without cache.
-
#render ⇒ Object
Render html tag with or without cache.
-
#tapped?(block) ⇒ Boolean
Know if component is tapped or not.
Methods included from PopoverExtension
#popover_data_html, #tooltip_data_html
Methods included from GlyphExtension
#generate_glyph, #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
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ui_bibz/ui/core/component.rb', line 61 def initialize(content = nil, = nil, = nil, &block) if !block.nil? @tapped = tapped?(block) = = content read_cache = Rails.cache.read(.try(:[], :cache)) if read_cache.nil? context = eval('self', block.binding) # rubocop:disable Style/EvalWithLocation @content = context.capture(&block) else @content = read_cache end elsif content.is_a?(Hash) = = content else = = @content = content end = ( || {}).with_indifferent_access = ( || {}).with_indifferent_access end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
54 55 56 |
# File 'lib/ui_bibz/ui/core/component.rb', line 54 def content @content end |
#html_options ⇒ Object
Returns the value of attribute html_options.
54 55 56 |
# File 'lib/ui_bibz/ui/core/component.rb', line 54 def end |
#options ⇒ Object
Returns the value of attribute options.
54 55 56 |
# File 'lib/ui_bibz/ui/core/component.rb', line 54 def end |
Instance Method Details
#pre_render ⇒ Object
Render without cache
93 94 95 |
# File 'lib/ui_bibz/ui/core/component.rb', line 93 def pre_render glyph_and_content_html end |
#render ⇒ Object
Render html tag with or without cache
88 89 90 |
# File 'lib/ui_bibz/ui/core/component.rb', line 88 def render render_with_or_without_cache end |
#tapped?(block) ⇒ Boolean
Know if component is tapped or not
98 99 100 |
# File 'lib/ui_bibz/ui/core/component.rb', line 98 def tapped?(block) UiBibz::Utils::Screwdriver.tapped?(block) end |