Class: UiBibz::Ui::Core::Component
- Inherits:
-
Base
- Object
- Base
- UiBibz::Ui::Core::Component
- 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:
-
state - State of élement with symbol value: (:default, :primary, :info, :warning, :danger)
-
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
Alert, Bar, Breadcrumb, BreadcrumbLink, Button, ButtonGroup, ButtonLink, Col, Dropdown, DropdownHeader, DropdownLink, Glyph, Jumbotron, Label, List, ListGroup, Nav, NavLink, Navbar, NavbarText, Panel, ProgressBar, Row, Stars, Ux::Column, Ux::Grid, Ux::Table
Instance Attribute Summary (collapse)
-
- (Object) content
Returns the value of attribute content.
-
- (Object) html_options
Returns the value of attribute html_options.
-
- (Object) options
Returns the value of attribute options.
Attributes inherited from Base
Instance Method Summary (collapse)
-
- (Object) add_classes(*classes)
Add classes in html_options.
-
- (Object) badge_html
Render badge html tag.
-
- (Object) class_and_html_options(classes = nil)
Add classes in html_options.
-
- (Object) glyph
Render glyph html.
-
- (Object) glyph_and_content_html
Render glyph and content html.
-
- (Object) glyph_with_space
Render glyph with space html.
-
- (Component) initialize(content = nil, options = nil, html_options = nil, &block)
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.
-
- (Object) render
Render html tag.
-
- (Object) state
Set :default state symbol.
Methods inherited from Base
Constructor Details
- (Component) initialize(content = nil, options = nil, html_options = nil, &block)
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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/ui_bibz/ui/core/component.rb', line 48 def initialize content = nil, = nil, = nil, &block if !block.nil? @html_options, @options = , content context = eval("self", block.binding) @content = context.capture(&block) else if content.kind_of?(Hash) @html_options, @options = , content else @html_options, @options, @content = , , content end end @html_options = @html_options || {} @options = @options || {} end |
Instance Attribute Details
- (Object) content
Returns the value of attribute content
41 42 43 |
# File 'lib/ui_bibz/ui/core/component.rb', line 41 def content @content end |
- (Object) html_options
Returns the value of attribute html_options
41 42 43 |
# File 'lib/ui_bibz/ui/core/component.rb', line 41 def @html_options end |
- (Object) options
Returns the value of attribute options
41 42 43 |
# File 'lib/ui_bibz/ui/core/component.rb', line 41 def @options end |
Instance Method Details
- (Object) add_classes(*classes)
Add classes in html_options
113 114 115 |
# File 'lib/ui_bibz/ui/core/component.rb', line 113 def add_classes *classes classes.compact.join(' ') end |
- (Object) badge_html
Render badge html tag
86 87 88 |
# File 'lib/ui_bibz/ui/core/component.rb', line 86 def badge_html content_tag :span, @options[:badge], class: 'badge' end |
- (Object) class_and_html_options(classes = nil)
Add classes in html_options
98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ui_bibz/ui/core/component.rb', line 98 def classes = nil = [:class] if .kind_of?(Hash) cls = [ [:class], status, state, ] cls << classes unless classes.nil? cls = cls.flatten.compact [:class] = cls.join(' ') unless cls.empty? end |
- (Object) glyph
Render glyph html
80 81 82 83 |
# File 'lib/ui_bibz/ui/core/component.rb', line 80 def glyph glyph_info = [:glyph] if .kind_of?(Hash) Glyph.new(glyph_info).render unless glyph_info.nil? end |
- (Object) glyph_and_content_html
Render glyph and content html
70 71 72 |
# File 'lib/ui_bibz/ui/core/component.rb', line 70 def glyph_and_content_html [glyph_with_space, @content].compact.join.html_safe end |
- (Object) glyph_with_space
Render glyph with space html
75 76 77 |
# File 'lib/ui_bibz/ui/core/component.rb', line 75 def glyph_with_space "#{ glyph } " unless glyph.nil? end |
- (Object) render
Render html tag
65 66 67 |
# File 'lib/ui_bibz/ui/core/component.rb', line 65 def render glyph_and_content_html end |
- (Object) state
Set :default state symbol
91 92 93 94 95 |
# File 'lib/ui_bibz/ui/core/component.rb', line 91 def state sym = .delete(:state) if [:state] sym = sym || :default states[:sym] end |